From 2e68b29d9cf810bfa248880e50213955e1712424 Mon Sep 17 00:00:00 2001 From: Lars Date: Sat, 21 Mar 2026 11:56:09 +0100 Subject: [PATCH] fix: improve Dashboard error handling and add debug logging - Add .catch() handler to load() Promise to prevent infinite loading state - Add console.log statements for component lifecycle debugging - Make EmailVerificationBanner/TrialBanner conditional on activeProfile - Ensure greeting header always renders with fallback This should fix the empty dashboard issue for new users. Co-Authored-By: Claude Opus 4.6 --- frontend/src/pages/Dashboard.jsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/frontend/src/pages/Dashboard.jsx b/frontend/src/pages/Dashboard.jsx index 536367d..586805c 100644 --- a/frontend/src/pages/Dashboard.jsx +++ b/frontend/src/pages/Dashboard.jsx @@ -247,6 +247,12 @@ export default function Dashboard() { setNutrition(n); setActivities(a) setInsights(Array.isArray(ins)?ins:[]) setLoading(false) + }).catch(err => { + console.error('Dashboard load failed:', err) + // Set empty data on error so UI can still render + setStats(null); setWeights([]); setCalipers([]); setCircs([]) + setNutrition([]); setActivities([]); setInsights([]) + setLoading(false) }) const runPipeline = async () => { @@ -260,7 +266,12 @@ export default function Dashboard() { } finally { setPipelineLoading(false) } } - useEffect(()=>{ load() },[]) + useEffect(()=>{ + console.log('[Dashboard] Component mounted, loading data...') + load() + },[]) + + console.log('[Dashboard] Rendering, loading=', loading, 'activeProfile=', activeProfile?.name) if (loading) return
@@ -304,6 +315,8 @@ export default function Dashboard() { const hasAnyData = latestW||latestCal||nutrition.length>0 + console.log('[Dashboard] hasAnyData=', hasAnyData, 'latestW=', !!latestW, 'latestCal=', !!latestCal, 'nutrition.length=', nutrition.length) + return (
{/* Header greeting */} @@ -318,10 +331,10 @@ export default function Dashboard() {
{/* Email Verification Banner */} - + {activeProfile && } {/* Trial Banner */} - + {activeProfile && } {!hasAnyData && (