Files
workavia-calendar-front/src/utils/findCalendarById.ts
T
2026-01-21 15:17:49 +01:00

18 lines
533 B
TypeScript

import { RootState } from "@/app/store";
import { Calendar } from "@/features/Calendars/CalendarTypes";
export function findCalendarById(
state: Partial<RootState>,
calendarId: string
): { calendar: Calendar; type?: "temp" } | undefined {
if (calendarId.length === 0) {
return;
}
if (state.calendars?.templist?.[calendarId]) {
return { calendar: state.calendars.templist[calendarId], type: "temp" };
}
if (state.calendars?.list?.[calendarId]) {
return { calendar: state.calendars.list[calendarId] };
}
}