aboutsummaryrefslogtreecommitdiffstats
path: root/src/containers/auth/AuthLayoutContainer.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/containers/auth/AuthLayoutContainer.tsx')
-rw-r--r--src/containers/auth/AuthLayoutContainer.tsx63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/containers/auth/AuthLayoutContainer.tsx b/src/containers/auth/AuthLayoutContainer.tsx
new file mode 100644
index 000000000..8d65ec6f4
--- /dev/null
+++ b/src/containers/auth/AuthLayoutContainer.tsx
@@ -0,0 +1,63 @@
1import { Component, ReactElement, ReactNode } from 'react';
2import { inject, observer } from 'mobx-react';
3import { ThemeProvider } from 'react-jss';
4
5import { DefaultProps } from 'src/@types/ferdium-components.types';
6import { Location } from 'mobx-react-router';
7import AuthLayout from '../../components/auth/AuthLayout';
8import AppLoader from '../../components/ui/AppLoader';
9
10interface AuthLayoutContainerProps extends DefaultProps {
11 location: Location;
12 children: ReactNode[] | ReactNode;
13}
14
15class AuthLayoutContainer extends Component<AuthLayoutContainerProps> {
16 render(): ReactElement {
17 const { stores, actions, children, location } = this.props;
18 const { app, features, globalError, user } = stores;
19
20 const isLoadingBaseFeatures =
21 features.defaultFeaturesRequest.isExecuting &&
22 !features.defaultFeaturesRequest.wasExecuted;
23
24 if (isLoadingBaseFeatures) {
25 return (
26 <ThemeProvider theme={stores.ui.theme}>
27 <AppLoader theme={stores.ui.theme} />
28 </ThemeProvider>
29 );
30 }
31
32 const { isLoggingOut } = user;
33 if (isLoggingOut) {
34 return (
35 <ThemeProvider theme={stores.ui.theme}>
36 <AppLoader theme={stores.ui.theme} texts={['Logging you out...']} />
37 </ThemeProvider>
38 );
39 }
40
41 return (
42 <ThemeProvider theme={stores.ui.theme}>
43 <AuthLayout
44 error={globalError.response}
45 pathname={location.pathname}
46 isOnline={app.isOnline}
47 isAPIHealthy={!app.healthCheckRequest.isError}
48 retryHealthCheck={actions.app.healthCheck}
49 isHealthCheckLoading={app.healthCheckRequest.isExecuting}
50 isFullScreen={app.isFullScreen}
51 installAppUpdate={actions.app.installUpdate}
52 appUpdateIsDownloaded={
53 app.updateStatus === app.updateStatusTypes.DOWNLOADED
54 }
55 >
56 {children}
57 </AuthLayout>
58 </ThemeProvider>
59 );
60 }
61}
62
63export default inject('stores', 'actions')(observer(AuthLayoutContainer));