1 import type { FunctionComponent } from 'react';
2 import { useState } from 'react';
3 import { Router } from 'react-router-dom';
17 import { c } from 'ttag';
21 AuthenticationProvider,
28 StandardLoadErrorPage,
30 SubscriptionModalProvider,
32 } from '@proton/components';
33 import useEffectOnce from '@proton/hooks/useEffectOnce';
34 import { ProtonStoreProvider } from '@proton/redux-shared-store';
35 import { WALLET_APP_NAME } from '@proton/shared/lib/constants';
36 import { getNonEmptyErrorMessage } from '@proton/shared/lib/helpers/error';
37 import { DRAWER_VISIBILITY } from '@proton/shared/lib/interfaces';
38 import { FlagProvider } from '@proton/unleash';
39 import ExtendedApiProvider from '@proton/wallet/contexts/ExtendedApiContext/ExtendedApiProvider';
40 import type { WalletStore } from '@proton/wallet/store';
41 import { extraThunkArguments } from '@proton/wallet/store/thunk';
42 import { isWasmSupported } from '@proton/wallet/utils/wasm';
44 import { type bootstrapApp } from './bootstrap';
45 import * as config from './config';
47 ChartJS.register(ArcElement, Tooltip, Legend, CategoryScale, LinearScale, PointElement, LineElement, Title, Filler);
49 const lazyBootstrapApp = (...args: Parameters<typeof bootstrapApp>) =>
50 import(/* webpackChunkName: "bootstrap" */ './bootstrap').then((result) => result.bootstrapApp(...args));
54 MainContainer?: FunctionComponent;
55 error?: { message: string } | undefined;
56 showDrawerSidebar?: boolean;
59 showDrawerSidebar: false,
62 const AppInner = () => {
63 const [state, setState] = useState(defaultState);
64 const notificationsManager = useNotifications();
69 const { scopes, userSettings, MainContainer, store } = await lazyBootstrapApp({
76 MainContainer: scopes.delinquent ? DelinquentContainer : MainContainer,
77 showDrawerSidebar: userSettings.HideSidePanel === DRAWER_VISIBILITY.SHOW,
79 } catch (error: any) {
82 message: getNonEmptyErrorMessage(error),
90 return <StandardLoadErrorPage errorMessage={state.error.message} />;
93 const loader = <LoaderPage />;
94 if (!state.MainContainer || !state.store) {
99 <ProtonStoreProvider store={state.store}>
100 <AuthenticationProvider store={extraThunkArguments.authentication}>
101 <FlagProvider unleashClient={extraThunkArguments.unleashClient} startClient={false}>
102 <Router history={extraThunkArguments.history}>
103 <EventManagerProvider eventManager={extraThunkArguments.eventManager}>
104 <ApiProvider api={extraThunkArguments.api}>
105 <ExtendedApiProvider walletApi={extraThunkArguments.walletApi}>
106 <ErrorBoundary big component={<StandardErrorPage big />}>
108 hasReadableMemberKeyActivation
109 hasMemberKeyMigration
110 hasPrivateMemberKeyGeneration
112 <SubscriptionModalProvider app={config.APP_NAME}>
113 <state.MainContainer />
114 </SubscriptionModalProvider>
115 </StandardPrivateApp>
117 </ExtendedApiProvider>
119 </EventManagerProvider>
122 </AuthenticationProvider>
123 </ProtonStoreProvider>
128 if (!isWasmSupported()) {
130 <div className="unsupported-wasm-container">
132 .t`Your browser or device software does not support ${WALLET_APP_NAME}. Please update your browser or device. Alternatively, you can use one of our mobile apps.`}</span>
138 <ProtonApp config={config}>