diff options
author | Ricardo Cino <ricardo@cino.io> | 2022-06-26 23:59:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-26 21:59:32 +0000 |
commit | 6bff2bb5439d25e0ab2a24a8ca1b28b89ef40ff9 (patch) | |
tree | 1676f5eef42b8086d28476c7eaad62c7b1753120 /src/containers/auth/AuthLayoutContainer.tsx | |
parent | Reduce tab item layout shift (#376) (diff) | |
download | ferdium-app-6bff2bb5439d25e0ab2a24a8ca1b28b89ef40ff9.tar.gz ferdium-app-6bff2bb5439d25e0ab2a24a8ca1b28b89ef40ff9.tar.zst ferdium-app-6bff2bb5439d25e0ab2a24a8ca1b28b89ef40ff9.zip |
chore: turned all auth containers into typescript (#375)
Diffstat (limited to 'src/containers/auth/AuthLayoutContainer.tsx')
-rw-r--r-- | src/containers/auth/AuthLayoutContainer.tsx | 63 |
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 @@ | |||
1 | import { Component, ReactElement, ReactNode } from 'react'; | ||
2 | import { inject, observer } from 'mobx-react'; | ||
3 | import { ThemeProvider } from 'react-jss'; | ||
4 | |||
5 | import { DefaultProps } from 'src/@types/ferdium-components.types'; | ||
6 | import { Location } from 'mobx-react-router'; | ||
7 | import AuthLayout from '../../components/auth/AuthLayout'; | ||
8 | import AppLoader from '../../components/ui/AppLoader'; | ||
9 | |||
10 | interface AuthLayoutContainerProps extends DefaultProps { | ||
11 | location: Location; | ||
12 | children: ReactNode[] | ReactNode; | ||
13 | } | ||
14 | |||
15 | class 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 | |||
63 | export default inject('stores', 'actions')(observer(AuthLayoutContainer)); | ||