refactor Notifications agenda
This commit is contained in:
parent
5c9a179c5a
commit
d55cc836ed
@ -109,6 +109,39 @@ export function Calendar() {
|
|||||||
|
|
||||||
console.log('Calendar Widget - Processed events:', upcomingEvents);
|
console.log('Calendar Widget - Processed events:', upcomingEvents);
|
||||||
setEvents(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);
|
setError(null);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error fetching events:', err);
|
console.error('Error fetching events:', err);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user