1 import { EVENT_ACTIONS } from '../../constants';
2 import type { CalendarWithOwnMembers } from '../../interfaces/calendar';
5 CalendarEventManagerCreate,
6 CalendarEventManagerDelete,
7 CalendarEventManagerUpdate,
8 CalendarMemberEventManager,
9 CalendarMemberEventManagerCreate,
10 CalendarMemberEventManagerDelete,
11 CalendarMemberEventManagerUpdate,
12 } from '../../interfaces/calendar/EventManager';
14 export const getIsCalendarEventManagerDelete = (event: CalendarEventManager): event is CalendarEventManagerDelete => {
15 return event.Action === EVENT_ACTIONS.DELETE;
17 export const getIsCalendarEventManagerCreate = (event: CalendarEventManager): event is CalendarEventManagerCreate => {
18 return event.Action === EVENT_ACTIONS.CREATE;
20 export const getIsCalendarEventManagerUpdate = (event: CalendarEventManager): event is CalendarEventManagerUpdate => {
21 return event.Action === EVENT_ACTIONS.UPDATE;
23 export const getIsCalendarMemberEventManagerDelete = (
24 event: CalendarMemberEventManager
25 ): event is CalendarMemberEventManagerDelete => {
26 return event.Action === EVENT_ACTIONS.DELETE;
28 export const getIsCalendarMemberEventManagerCreate = (
29 event: CalendarMemberEventManager
30 ): event is CalendarMemberEventManagerCreate => {
31 return event.Action === EVENT_ACTIONS.CREATE;
33 export const getIsCalendarMemberEventManagerUpdate = (
34 event: CalendarMemberEventManager
35 ): event is CalendarMemberEventManagerUpdate => {
36 return event.Action === EVENT_ACTIONS.UPDATE;
38 export const findMemberIndices = (
40 calendarsWithMembers: CalendarWithOwnMembers[],
41 memberCalendarID?: string
43 let calendarIndex = -1;
46 calendarsWithMembers.forEach(({ ID, Members }, i) => {
47 if (ID === memberCalendarID) {
50 Members.forEach(({ ID }, j) => {
51 if (ID === memberID) {
58 return [calendarIndex, memberIndex];