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
64
65
66
67
68
69
70
71
72
73
74
75
|
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { inject, observer } from 'mobx-react';
import { ThemeProvider } from 'react-jss';
import { theme } from '@meetfranz/theme';
import AuthLayout from '../../components/auth/AuthLayout';
import AppStore from '../../stores/AppStore';
import GlobalErrorStore from '../../stores/GlobalErrorStore';
import AppLoader from '../../components/ui/AppLoader';
import { oneOrManyChildElements } from '../../prop-types';
export default @inject('stores', 'actions') @observer class AuthLayoutContainer extends Component {
static propTypes = {
children: oneOrManyChildElements.isRequired,
location: PropTypes.shape({
pathname: PropTypes.string.isRequired,
}).isRequired,
};
render() {
const {
stores, actions, children, location,
} = this.props;
const {
app, features, globalError, settings,
} = stores;
const isLoadingBaseFeatures = features.defaultFeaturesRequest.isExecuting
&& !features.defaultFeaturesRequest.wasExecuted;
const themeType = theme(settings.app.darkMode ? 'dark' : 'default');
if (isLoadingBaseFeatures) {
return (
<ThemeProvider theme={theme(themeType)}>
<AppLoader />
</ThemeProvider>
);
}
return (
<ThemeProvider theme={theme(themeType)}>
<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}
darkMode={app.isSystemDarkModeEnabled}
installAppUpdate={actions.app.installUpdate}
nextAppReleaseVersion={app.nextAppReleaseVersion}
appUpdateIsDownloaded={app.updateStatus === app.updateStatusTypes.DOWNLOADED}
>
{children}
</AuthLayout>
</ThemeProvider>
);
}
}
AuthLayoutContainer.wrappedComponent.propTypes = {
stores: PropTypes.shape({
app: PropTypes.instanceOf(AppStore).isRequired,
globalError: PropTypes.instanceOf(GlobalErrorStore).isRequired,
}).isRequired,
actions: PropTypes.shape({
app: PropTypes.shape({
healthCheck: PropTypes.func.isRequired,
}).isRequired,
}).isRequired,
};
|