From cf37400d34f1f4326dbece2650746dd4bdebd2e3 Mon Sep 17 00:00:00 2001 From: Daniel Volz Date: Mon, 29 Dec 2025 20:29:46 +0100 Subject: [PATCH] feat: reset planner and range on user change for improved state management --- frontend/src/App.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 5ddfb82..1846346 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -273,6 +273,9 @@ function AppContent() { } else { setRange({ start: toInputValue(todayIso()), end: toInputValue(plusDaysIso(3)) }); } + } else { + setPlannerRows([]); + setRange({ start: toInputValue(todayIso()), end: toInputValue(plusDaysIso(3)) }); } }, [user?.id]); @@ -570,10 +573,14 @@ function AppContent() { const pastDays = useMemo(() => groupedSchedule.filter(d => d.isPast), [groupedSchedule]); const futureDays = useMemo(() => groupedSchedule.filter(d => !d.isPast).slice(0, scheduleDays), [groupedSchedule, scheduleDays]); + // Load medications and settings when user changes (or on initial mount) useEffect(() => { loadMeds(); loadSettings(); - }, []); + // Reset planner when user changes + setPlannerRows([]); + setRange({ start: toInputValue(todayIso()), end: toInputValue(plusDaysIso(3)) }); + }, [user?.id]); function loadMeds() { setLoading(true);