From d55cc836edc45d6a4edc184a2c29959a7c858bfd Mon Sep 17 00:00:00 2001 From: alma Date: Fri, 16 Jan 2026 02:55:21 +0100 Subject: [PATCH] refactor Notifications agenda --- components/calendar.tsx | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/components/calendar.tsx b/components/calendar.tsx index 350b45e..851e455 100644 --- a/components/calendar.tsx +++ b/components/calendar.tsx @@ -109,6 +109,39 @@ export function Calendar() { console.log('Calendar Widget - Processed events:', upcomingEvents); setEvents(upcomingEvents); + + // Dispatch event for Outlook-style notifications (when events start) + const eventsForNotification = upcomingEvents.map(evt => ({ + id: evt.id, + title: evt.title, + start: evt.start instanceof Date ? evt.start : new Date(evt.start), + end: evt.end instanceof Date ? evt.end : new Date(evt.end), + isAllDay: evt.allDay, + calendarName: evt.calendar, + calendarColor: evt.calendarColor, + })); + + console.log('[Calendar Widget] 📅 Dispatching calendar events update', { + eventsCount: eventsForNotification.length, + events: eventsForNotification.map(e => ({ + id: e.id, + title: e.title, + start: e.start instanceof Date ? e.start.toISOString() : e.start, + isAllDay: e.isAllDay, + })), + }); + + try { + window.dispatchEvent(new CustomEvent('calendar-events-updated', { + detail: { + events: eventsForNotification, + } + })); + console.log('[Calendar Widget] ✅ Event dispatched successfully'); + } catch (error) { + console.error('[Calendar Widget] ❌ Error dispatching event', error); + } + setError(null); } catch (err) { console.error('Error fetching events:', err);