From b2d6bcae5e080a496e3dbf80f96d0341e8cbc96f Mon Sep 17 00:00:00 2001 From: Alma Date: Sun, 13 Apr 2025 16:09:09 +0200 Subject: [PATCH] calendar 26 --- components/calendar/calendar-client.tsx | 60 +++++++++++++++++-------- 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/components/calendar/calendar-client.tsx b/components/calendar/calendar-client.tsx index c09a6e73..24aee2c1 100644 --- a/components/calendar/calendar-client.tsx +++ b/components/calendar/calendar-client.tsx @@ -480,6 +480,15 @@ export function CalendarClient({ initialCalendars, userId, userProfile }: Calend const calendarRef = useRef(null); + const [visibleCalendarIds, setVisibleCalendarIds] = useState([]); + + // Update useEffect to initialize visible calendars + useEffect(() => { + if (calendars.length > 0) { + setVisibleCalendarIds(calendars.map(cal => cal.id)); + } + }, [calendars]); + const fetchCalendars = async () => { try { setLoading(true); @@ -799,21 +808,32 @@ export function CalendarClient({ initialCalendars, userId, userProfile }: Calend } }; - // Update CalendarSelector to use the new handler + // Update CalendarSelector to handle visibility const CalendarSelector = () => (
{calendars.map((calendar) => (
{calendar.name !== "Calendrier principal" && (