export type ScheduleViewMode = 'list' | 'calendar'; export type ScheduleRange = 'day' | 'week' | 'month' | 'year'; type Span = Exclude; const LIST_VIEWS: Record = { day: 'listDay', week: 'listWeek', month: 'listMonth' }; const CALENDAR_VIEWS: Record = { day: 'timeGridDay', week: 'timeGridWeek', month: 'dayGridMonth' }; /** * The FullCalendar view for a mode and range. On a phone a seven-column week or month leaves each day * about 45px, too narrow to read a name, so those calendars show as the same span's agenda instead. */ export const getFullCalendarView = (viewMode: ScheduleViewMode, range: ScheduleRange, phone = false): string => { if (range === 'year') return 'listYear'; if (viewMode === 'list') return LIST_VIEWS[range]; if (phone && range !== 'day') return LIST_VIEWS[range]; return CALENDAR_VIEWS[range]; };