1 import type { FunctionComponent } from 'react';
2 import { useState } from 'react';
3 import { Router } from 'react-router-dom';
7 AuthenticationProvider,
8 CalendarModelEventManagerProvider,
16 StandardLoadErrorPage,
18 SubscriptionModalProvider,
19 } from '@proton/components';
20 import useEffectOnce from '@proton/hooks/useEffectOnce';
21 import { ProtonStoreProvider } from '@proton/redux-shared-store';
22 import { APPS } from '@proton/shared/lib/constants';
23 import { getNonEmptyErrorMessage } from '@proton/shared/lib/helpers/error';
24 import { DRAWER_VISIBILITY } from '@proton/shared/lib/interfaces';
25 import { FlagProvider } from '@proton/unleash';
27 import { bootstrapApp } from './bootstrap';
28 import * as config from './config';
29 import type { CalendarStore } from './store/store';
30 import { extraThunkArguments } from './store/thunk';
33 store?: CalendarStore;
34 MainContainer?: FunctionComponent;
35 error?: { message: string } | undefined;
36 showDrawerSidebar?: boolean;
39 showDrawerSidebar: false,
43 const [state, setState] = useState(defaultState);
48 const { MainContainer, scopes, userSettings, store } = await bootstrapApp({ config });
50 MainContainer: scopes.delinquent ? DelinquentContainer : MainContainer,
52 showDrawerSidebar: userSettings.HideSidePanel === DRAWER_VISIBILITY.SHOW,
54 } catch (error: any) {
57 message: getNonEmptyErrorMessage(error),
65 <ProtonApp config={config}>
68 return <StandardLoadErrorPage errorMessage={state.error.message} />;
70 const loader = <LoaderPage />;
71 if (!state.MainContainer || !state.store) {
75 <ProtonStoreProvider store={state.store}>
76 <AuthenticationProvider store={extraThunkArguments.authentication}>
77 <FlagProvider unleashClient={extraThunkArguments.unleashClient} startClient={false}>
78 <Router history={extraThunkArguments.history}>
79 <EventManagerProvider eventManager={extraThunkArguments.eventManager}>
80 <ApiProvider api={extraThunkArguments.api}>
81 <DrawerProvider defaultShowDrawerSidear={state.showDrawerSidebar}>
82 <SubscriptionModalProvider app={APPS.PROTONCALENDAR}>
83 <CalendarModelEventManagerProvider
84 calendarModelEventManager={
85 extraThunkArguments.calendarModelEventManager
88 <ErrorBoundary big component={<StandardErrorPage big />}>
90 hasReadableMemberKeyActivation
92 hasPrivateMemberKeyGeneration
94 <state.MainContainer />
97 </CalendarModelEventManagerProvider>
98 </SubscriptionModalProvider>
101 </EventManagerProvider>
104 </AuthenticationProvider>
105 </ProtonStoreProvider>