import { Calendar, CalendarEvent } from '/lib/models/calendar.ts'; import { convertRRuleToWords } from '/lib/utils/calendar.ts'; interface ViewEventModalProps { isOpen: boolean; calendarEvent: CalendarEvent; calendar: Calendar; onClickDelete: (eventId: string) => void; onClose: () => void; timezoneId: string; } export default function ViewEventModal( { isOpen, calendarEvent, calendar, onClickDelete, onClose, timezoneId }: ViewEventModalProps, ) { if (!calendarEvent || !calendar) { return null; } const allDayEventDateFormat = new Intl.DateTimeFormat('en-GB', { year: 'numeric', month: 'long', day: 'numeric', timeZone: timezoneId, // Calendar dates are parsed without timezone info, so we need to force to a specific one so it's consistent across db, server, and client }); const hourFormat = new Intl.DateTimeFormat('en-GB', { hour12: false, hour: '2-digit', minute: '2-digit', timeZone: timezoneId, // Calendar dates are parsed without timezone info, so we need to force to a specific one so it's consistent across db, server, and client }); return ( <>

{calendarEvent.title}

{calendarEvent.startDate ? allDayEventDateFormat.format(new Date(calendarEvent.startDate)) : ''} {calendarEvent.isAllDay ? All-day : ( {calendarEvent.startDate ? hourFormat.format(new Date(calendarEvent.startDate)) : ''} -{' '} {calendarEvent.endDate ? hourFormat.format(new Date(calendarEvent.endDate)) : ''} )}
{calendar.displayName}
{calendarEvent.description ? (
{calendarEvent.description}
) : null} {calendarEvent.eventUrl ? (
{calendarEvent.eventUrl}
) : null} {calendarEvent.location ? (
{calendarEvent.location}
) : null} {Array.isArray(calendarEvent.attendees) && calendarEvent.attendees.length > 0 ? (
{calendarEvent.attendees.map((attendee) => (

{attendee.name || attendee.email} {' '} - {attendee.status}

))}
) : null} {calendarEvent.isRecurring && calendarEvent.recurringRrule ? (

Repeats {convertRRuleToWords(calendarEvent.recurringRrule, { capitalizeSentence: false })}.

) : null} {Array.isArray(calendarEvent.reminders) && calendarEvent.reminders.length > 0 ? (
{calendarEvent.reminders.map((reminder) => (

{reminder.description || 'Reminder'} at {hourFormat.format(new Date(reminder.startDate))} via{' '} {reminder.type}.

))}
) : null}
); }