2018-02-26 00:11:31 +00:00
|
|
|
import React, { Component } from 'react';
|
2019-06-03 20:32:54 +00:00
|
|
|
import { Redirect, Route, Switch } from 'react-router';
|
2018-02-26 00:11:31 +00:00
|
|
|
|
|
|
|
import AppRouting from './AppRouting';
|
2018-03-03 22:41:57 +00:00
|
|
|
import SnackbarNotification from './components/SnackbarNotification';
|
|
|
|
|
2018-05-18 22:29:14 +00:00
|
|
|
import CssBaseline from '@material-ui/core/CssBaseline';
|
|
|
|
import blueGrey from '@material-ui/core/colors/blueGrey';
|
|
|
|
import indigo from '@material-ui/core/colors/indigo';
|
|
|
|
import orange from '@material-ui/core/colors/orange';
|
|
|
|
import red from '@material-ui/core/colors/red';
|
|
|
|
import green from '@material-ui/core/colors/green';
|
|
|
|
|
2018-02-26 00:11:31 +00:00
|
|
|
import { create } from 'jss';
|
2019-05-24 11:19:27 +00:00
|
|
|
import { StylesProvider, jssPreset } from '@material-ui/styles';
|
2018-02-26 00:11:31 +00:00
|
|
|
|
|
|
|
import {
|
|
|
|
MuiThemeProvider,
|
2019-05-24 11:19:27 +00:00
|
|
|
createMuiTheme
|
2018-05-18 22:29:14 +00:00
|
|
|
} from '@material-ui/core/styles';
|
2018-02-26 00:11:31 +00:00
|
|
|
|
|
|
|
// Our theme
|
|
|
|
const theme = createMuiTheme({
|
|
|
|
palette: {
|
|
|
|
primary: indigo,
|
|
|
|
secondary: blueGrey,
|
|
|
|
highlight_idle: blueGrey[900],
|
|
|
|
highlight_warn: orange[500],
|
|
|
|
highlight_error: red[500],
|
|
|
|
highlight_success: green[500],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// JSS instance
|
|
|
|
const jss = create(jssPreset());
|
|
|
|
|
2019-06-03 20:32:54 +00:00
|
|
|
// this redirect forces a call to authenticationContext.refresh() which invalidates the JWT if it is invalid.
|
|
|
|
const unauthorizedRedirect = () => <Redirect to="/" />;
|
|
|
|
|
|
|
|
class App extends Component {
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<StylesProvider jss={jss}>
|
|
|
|
<MuiThemeProvider theme={theme}>
|
|
|
|
<SnackbarNotification>
|
|
|
|
<CssBaseline />
|
|
|
|
<Switch>
|
|
|
|
<Route exact path="/unauthorized" component={unauthorizedRedirect} />
|
|
|
|
<Route component={AppRouting} />
|
|
|
|
</Switch>
|
|
|
|
</SnackbarNotification>
|
|
|
|
</MuiThemeProvider>
|
|
|
|
</StylesProvider>
|
|
|
|
);
|
|
|
|
}
|
2018-02-26 00:11:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default App
|