1 import type { CalendarUserSettings } from '../interfaces/calendar';
2 import { SETTINGS_VIEW, VIEWS } from './constants';
4 export const getAutoDetectPrimaryTimezone = (calendarUserSettings: CalendarUserSettings) => {
5 return !!calendarUserSettings.AutoDetectPrimaryTimezone;
8 export const getDisplaySecondaryTimezone = (calendarUserSettings: CalendarUserSettings) => {
9 return !!calendarUserSettings.DisplaySecondaryTimezone;
12 export const getSecondaryTimezone = (calendarUserSettings: CalendarUserSettings) => {
13 return calendarUserSettings.SecondaryTimezone;
16 export const getDisplayWeekNumbers = (calendarUserSettings: CalendarUserSettings) => {
17 return !!calendarUserSettings.DisplayWeekNumber;
20 export const getDefaultCalendarID = (calendarUserSettings: CalendarUserSettings) => {
21 // DefaultCalendarID is either null or a string
22 return calendarUserSettings.DefaultCalendarID || undefined;
25 export const getInviteLocale = (calendarUserSettings: CalendarUserSettings) => {
26 // InviteLocale is either null or a string
27 return calendarUserSettings.InviteLocale || undefined;
30 export const getDefaultTzid = (calendarUserSettings: CalendarUserSettings, defaultTimezone: string) => {
31 const primaryTimezone = calendarUserSettings.PrimaryTimezone;
32 return primaryTimezone || defaultTimezone;
35 const SETTINGS_VIEW_CONVERSION = {
36 [SETTINGS_VIEW.YEAR]: VIEWS.WEEK,
37 [SETTINGS_VIEW.PLANNING]: VIEWS.WEEK,
38 [SETTINGS_VIEW.MONTH]: VIEWS.MONTH,
39 [SETTINGS_VIEW.WEEK]: VIEWS.WEEK,
40 [SETTINGS_VIEW.DAY]: VIEWS.DAY,
43 export const getDefaultView = (calendarUserSettings: CalendarUserSettings) => {
44 return SETTINGS_VIEW_CONVERSION[calendarUserSettings?.ViewPreference] || VIEWS.WEEK;