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
76
77
78
79
|
import React from 'react';
import { Switch, Route } from 'react-router-dom';
import NotFound from 'containers/Pages/Standalone/NotFoundDedicated';
import Auth from './Auth';
import Application from './Application';
import LoginDedicated from '../Pages/Standalone/LoginDedicated';
import ThemeWrapper from './ThemeWrapper';
import { Snackbar, Button, Icon } from '@material-ui/core';
import { connect } from 'react-redux';
window.__MUI_USE_NEXT_TYPOGRAPHY_VARIANTS__ = true;
function App(props) {
const handleMessageClose = () => {
props.dispatch(closeMessage())
}
const {
openMessage = false,
message = '',
type = 'error'
} = props
return (
<ThemeWrapper>
<Snackbar
anchorOrigin={{
vertical: 'top',
horizontal: 'right',
}}
open={openMessage}
autoHideDuration={6000}
onClose={handleMessageClose}
message={
<div className="center-aligned-child">
<Icon style={{
fontSize: 20,
marginRight: 15
}} >
{type === 'success' ? 'check_circle' : 'report_problem'}
</Icon>
{message}
</div>
}
action={[
<Button key="undo" color="secondary" size="small" onClick={handleMessageClose}>
<Icon>
{'close'}
</Icon>
</Button>
]}
/>
<Switch>
<Route path="/" exact component={LoginDedicated} />
<Route path="/app" component={Application} />
<Route component={Auth} />
<Route component={NotFound} />
</Switch>
</ThemeWrapper>
);
}
const reducer = 'message';
const mapStateToProps = state => ({
force: state, // force state from reducer
message: state.getIn([reducer, 'message']),
type: state.getIn([reducer, 'type']),
openMessage: state.getIn([reducer, 'openMessage'])
});
const mapDispatchToProps = dispatch => ({
dispatch: dispatch
});
const AppMapped = connect(
mapStateToProps,
mapDispatchToProps
)(App);
export default AppMapped;
|