Cleanup - unused files / unused exports / duplicate exports
[ProtonMail-WebClient.git] / packages / components / containers / eventManager / calendar / CalendarModelEventManagerProvider.tsx
blob8f67e2e61d6086554d4866bb324dbfb4541c1088
1 import type { ReactNode } from 'react';
2 import { createContext, useContext } from 'react';
4 import type { CalendarModelEventManager } from '@proton/calendar';
6 const CalendarModelEventManagerContext = createContext<CalendarModelEventManager | null>(null);
8 interface Props {
9     children: ReactNode;
10     calendarModelEventManager: CalendarModelEventManager;
13 const CalendarModelEventManagerProvider = ({ children, calendarModelEventManager }: Props) => {
14     return (
15         <CalendarModelEventManagerContext.Provider value={calendarModelEventManager}>
16             {children}
17         </CalendarModelEventManagerContext.Provider>
18     );
21 export const useCalendarModelEventManager = () => {
22     const state = useContext(CalendarModelEventManagerContext);
23     if (!state) {
24         throw new Error('Trying to use uninitialized ModelEventManagerProvider');
25     }
26     return state;
29 export default CalendarModelEventManagerProvider;