blob: 1f2753a661b29f24795866fc2402718b073a21ff (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
import { Component, ReactElement, ReactNode } from 'react';
import { inject, observer } from 'mobx-react';
import { ThemeProvider } from 'react-jss';
import { Location } from 'mobx-react-router';
import { StoresProps } from '../../@types/ferdium-components.types';
import AuthLayout from '../../components/auth/AuthLayout';
import AppLoader from '../../components/ui/AppLoader';
interface AuthLayoutContainerProps extends StoresProps {
location: Location;
children: ReactNode;
}
class AuthLayoutContainer extends Component<AuthLayoutContainerProps> {
render(): ReactElement {
const { stores, actions, children, location } = this.props;
const { app, features, globalError, user } = stores;
const isLoadingBaseFeatures =
features.defaultFeaturesRequest.isExecuting &&
!features.defaultFeaturesRequest.wasExecuted;
if (isLoadingBaseFeatures) {
return (
<ThemeProvider theme={stores.ui.theme}>
<AppLoader theme={stores.ui.theme} />
</ThemeProvider>
);
}
const { isLoggingOut } = user;
if (isLoggingOut) {
return (
<ThemeProvider theme={stores.ui.theme}>
<AppLoader theme={stores.ui.theme} texts={['Logging you out...']} />
</ThemeProvider>
);
}
return (
<ThemeProvider theme={stores.ui.theme}>
<AuthLayout
error={globalError.response}
pathname={location.pathname}
isOnline={app.isOnline}
isAPIHealthy={!app.healthCheckRequest.isError}
retryHealthCheck={actions.app.healthCheck}
isHealthCheckLoading={app.healthCheckRequest.isExecuting}
isFullScreen={app.isFullScreen}
installAppUpdate={actions.app.installUpdate}
appUpdateIsDownloaded={
app.updateStatus === app.updateStatusTypes.DOWNLOADED
}
>
{children}
</AuthLayout>
</ThemeProvider>
);
}
}
export default inject('stores', 'actions')(observer(AuthLayoutContainer));
|