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AAK,SAAAkB,GACF,OAAOA,EAAShB,IACpB,IAAG,SAACiB,GACA,OAAOC,QAAQC,QAAO,QAAYF,GACtC,GACR,EAESkB,EAAuB,SAAChD,GACjC,OAAO,KAAQ4B,KAAmB,qBAAc5B,EAAU,eAAe,CAAC,EAC9E,EAEaiD,EAAgB,WACzB,OAAO,KAAQrB,KAAmB,wBAAyB,CAAC,EAChE,C","sources":["entities/calendar.ts","services/api/calendar.ts"],"sourcesContent":["import Moment from 'moment';\r\nimport { IServiceIntervalRequest, IServiceArriveTimeRequest } from './service';\r\n\r\nexport const enum CalendarType {\r\n    Classic = 1,\r\n    Timetable = 2\r\n}\r\n\r\nexport interface IInterval {\r\n    Start: string,\r\n    End: string,\r\n    Reserved?: boolean,\r\n}\r\n\r\nexport interface IDateInterval {\r\n    Date: string;\r\n    Intervals: IInterval[];\r\n}\r\n\r\nexport interface IDateIntervalByCalendar {\r\n    Intervals: IDateInterval[],\r\n    CalendarId: number,\r\n    DayStart: string,\r\n    DayEnd: string\r\n}\r\n\r\nexport interface ICalendarBase {\r\n    Id: number;\r\n    Name: string;\r\n    Type: CalendarType;\r\n}\r\n\r\nexport const enum TimeTableViewType {\r\n    AgendaDay,\r\n    BasicDay,\r\n    AgendaWeek,\r\n    BasicWeek,\r\n    Month\r\n}\r\n\r\nexport const enum ClassicViewType {\r\n    DateAndTime,\r\n    Calendar\r\n}\r\n\r\nexport interface ICalendar extends ICalendarBase {\r\n    WeeksForward: number;\r\n    ConcurrentNum: number;\r\n    DayStart: string;\r\n    DayEnd: string;\r\n    MinTimeModify: number;\r\n    MinTimeReserve: number;\r\n    Readonly: boolean;\r\n    ShortDescription: string | null;\r\n    Description: string | null;\r\n    PictureLink: string | null;\r\n    GoogleCalendarName?: string;\r\n    WeekendDisabled: boolean;\r\n    UserViewSlotMinutes: number;\r\n    ClassicCustomerViewType: ClassicViewType;\r\n    DefaultCustomerView: TimeTableViewType;\r\n    IsTimeSelectDropDown: boolean;\r\n    HideSeatCount: boolean;\r\n    PhoneNumber?: string;\r\n}\r\n\r\nexport interface ICalendarIntervals {\r\n    Intervals: IDateInterval[];\r\n    MinTimeReserve: number\r\n}\r\n\r\nexport interface ICalendarIntervalRequest extends IServiceIntervalRequest {\r\n    calendarId: number;\r\n}\r\nexport interface ICalendarAllIntervalRequest {\r\n    calendarIds: string[];\r\n    startDate: string;\r\n    endDate: string;\r\n    personCount?: number;\r\n}\r\n\r\nexport interface ICalendarArriveTimeRequest extends IServiceArriveTimeRequest {\r\n    calendarId: number;\r\n}\r\n\r\nexport const randomCalendarItem: ICalendar = {\r\n    Id: 0,\r\n    Name: 'Mindegy',\r\n    WeeksForward: 0,\r\n    ConcurrentNum: 0,\r\n    Readonly: false,\r\n    Type: 0,\r\n    DayStart: '08:00',\r\n    DayEnd: '20:00',\r\n    Description: '',\r\n    ShortDescription: '',\r\n    MinTimeModify: 0,\r\n    MinTimeReserve: 0,\r\n    PictureLink: '',\r\n    WeekendDisabled: false,\r\n    UserViewSlotMinutes: 60,\r\n    ClassicCustomerViewType: ClassicViewType.DateAndTime,\r\n    DefaultCustomerView: TimeTableViewType.Month,\r\n    IsTimeSelectDropDown: false,\r\n    HideSeatCount: false\r\n};\r\n\r\nexport const isRandomCalendar = (calendarId: number): boolean => {\r\n    return calendarId === 0;\r\n}\r\n\r\nexport const isAppointmentCalendar = (calendar?: ICalendar): boolean => {\r\n    if (!calendar) {\r\n        return false;\r\n    }\r\n    return calendar.ClassicCustomerViewType === ClassicViewType.Calendar;\r\n}\r\n\r\nexport const getCalendarMaxDate = (weeksForward: number): string => {\r\n    return Moment().add(weeksForward, 'weeks').endOf('week').toISOString()\r\n}","import fetcher from '../fetcher';\r\nimport { ICalendar, IDateInterval, ICalendarIntervals, ICalendarIntervalRequest, CalendarType, ICalendarArriveTimeRequest, ICalendarAllIntervalRequest, IDateIntervalByCalendar } from './../../entities/calendar';\r\nimport { IDTO, IResponseDto } from './../../entities/common';\r\nimport { handleError } from './errorHandler';\r\n\r\nexport const getCalendars = (): Promise<ICalendar[]> => {\r\n    return fetcher.get<IDTO<ICalendar[]>>('/Calendars/WithDetails')\r\n        .then(respJson => respJson.Data || [])\r\n};\r\n\r\nexport const getCalendarById = (calendarId?: number): Promise<ICalendar> => {\r\n    return fetcher.get<IDTO<ICalendar>>(`/Calendars/${calendarId}`)\r\n        .then((respJson) => respJson.Data);\r\n};\r\n\r\nexport const getCalendarsByService = (id: number): Promise<ICalendar[]> => {\r\n    return fetcher.get<IDTO<ICalendar[]>>(`/Services/${id}/Calendars/WithDetails`)\r\n        .then(respJson => respJson.Data.filter(calendar => calendar.Type !== CalendarType.Timetable) || [], () => []);\r\n};\r\n\r\nexport const getCalendarFirstFreeSlot = (calendarId: number, serviceId?: number): Promise<string> => {\r\n    const params = serviceId ?\r\n        '?' + new URLSearchParams({\r\n            ServiceId: '' + serviceId,\r\n        }).toString() : ''\r\n    return fetcher.get<IDTO<string>>(`/Calendars/${calendarId}/FirstFreeSlot${params}`)\r\n        .then((respJson) => respJson.Data || '')\r\n        .catch(() => '');\r\n};\r\n\r\nexport const getCalendarDaysWithFreeIntervals =\r\n    (request: ICalendarIntervalRequest): Promise<string[] | null> => {\r\n        return fetcher.post<IDTO<string[]>>(`/Calendars/${request.calendarId}/DaysWithFreeIntervals`, request)\r\n            .then(response => {\r\n                return response.Data\r\n            }, (errorDto: IResponseDto) => {\r\n                return Promise.reject(handleError(errorDto));\r\n            });\r\n    };\r\n\r\n/**\r\n * Fetch free appointment time intervals on a given day or in a set of days\r\n * @property startDate - Single day or first in a set of days\r\n * @property [endDate] - Last in a set days\r\n */\r\nexport const getCalendarFreeIntervals =\r\n    (request: ICalendarIntervalRequest): Promise<IDateInterval[] | null> => {\r\n        request.endDate = request.endDate || request.startDate\r\n\r\n        return fetcher.post<IDTO<ICalendarIntervals>>(`/Calendars/${request.calendarId}/FreeIntervals`, request)\r\n            .then(response => {\r\n                return response.Data.Intervals\r\n            }, (errorDto: IResponseDto) => {\r\n                return Promise.reject(handleError(errorDto));\r\n            });\r\n    }\r\n\r\nexport const getCalendarAllIntervals =\r\n    (request: ICalendarAllIntervalRequest): Promise<IDateIntervalByCalendar[] | null> => {\r\n        request.endDate = request.endDate || request.startDate;\r\n        const calendarIdsParam = new URLSearchParams(\r\n            request.calendarIds.map(s => ['calendarIds', s]));\r\n\r\n        const params = new URLSearchParams({\r\n            StartDate: request.startDate,\r\n            EndDate: request.endDate,\r\n            UseSlotMinutes: false.toString()\r\n        });\r\n\r\n        const queryString = '?' + params.toString() + '&' + calendarIdsParam.toString();\r\n\r\n        return fetcher.get<IDTO<IDateIntervalByCalendar[]>>(`/Calendars/AllIntervals${queryString}`)\r\n            .then(response => {\r\n                return response.Data\r\n            }, (errorDto: IResponseDto) => {\r\n                return Promise.reject(handleError(errorDto));\r\n            });\r\n    }\r\n\r\nexport const getCalendarArriveTimes =\r\n    (request: ICalendarArriveTimeRequest): Promise<string[]> => {\r\n        const params = \r\n            '?' + new URLSearchParams({\r\n                ServiceId: '' + request.serviceId,\r\n                Date: request.startDate\r\n            }).toString()\r\n\r\n        return fetcher.get<IDTO<string[]>>(`/Calendars/${request.calendarId}/ArrivalTimes${params}`)\r\n            .then(response => {\r\n                return response.Data\r\n            }, (errorDto: IResponseDto) => {\r\n                return Promise.reject(handleError(errorDto));\r\n            });\r\n    }\r\n\r\nexport const googleSyncByCalendar = (calendarId: number): Promise<IResponseDto> => {\r\n    return fetcher.post<IResponseDto>(`/Calendars/${calendarId}/GoogleSync`, {});\r\n}\r\n\r\nexport const googleSyncAll = (): Promise<IResponseDto> => {\r\n    return fetcher.post<IResponseDto>(`/Calendars/GoogleSync`, {});\r\n}"],"names":["CalendarType","TimeTableViewType","ClassicViewType","randomCalendarItem","Id","Name","WeeksForward","ConcurrentNum","Readonly","Type","DayStart","DayEnd","Description","ShortDescription","MinTimeModify","MinTimeReserve","PictureLink","WeekendDisabled","UserViewSlotMinutes","ClassicCustomerViewType","DateAndTime","DefaultCustomerView","Month","IsTimeSelectDropDown","HideSeatCount","isRandomCalendar","calendarId","isAppointmentCalendar","calendar","Calendar","getCalendarMaxDate","weeksForward","add","endOf","toISOString","getCalendars","get","then","respJson","Data","getCalendarById","getCalendarsByService","id","filter","Timetable","getCalendarFirstFreeSlot","serviceId","params","URLSearchParams","ServiceId","toString","catch","getCalendarDaysWithFreeIntervals","request","post","response","errorDto","Promise","reject","getCalendarFreeIntervals","endDate","startDate","Intervals","getCalendarAllIntervals","calendarIdsParam","calendarIds","map","s","queryString","StartDate","EndDate","UseSlotMinutes","getCalendarArriveTimes","Date","googleSyncByCalendar","googleSyncAll"],"sourceRoot":""}