-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.jsx
47 lines (43 loc) · 1.34 KB
/
index.jsx
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
import React from 'react';
import { Route, Router, Switch } from 'react-router-dom';
import { Provider } from 'react-redux';
import ReactDOM from 'react-dom';
import styled from 'styled-components';
import store from './redux/store';
import LandingPage from './pages/LandingPage';
import HomePage from './pages/HomePage';
import Loading from './components/Loading';
import Auth from './auth/Auth';
import history from './utils/history';
import './index.css';
const auth = new Auth();
const RouteContainer = styled.div`
height: 100%;
width: 100%;
`;
const handleAuthentication = (nextState) => {
if (/access_token|id_token|error/.test(nextState.location.hash)) {
auth.handleAuthentication();
}
};
const Root = () => (
<Provider store={store}>
<Router history={history}>
<RouteContainer>
<Switch>
<Route exact path="/" render={props => <LandingPage auth={auth} {...props} />} />
<Route exact path="/home" render={props => <HomePage auth={auth} {...props} />} />
<Route
exact
path="/auth-callback"
render={(props) => {
handleAuthentication(props);
return <Loading {...props} />;
}}
/>;
</Switch>
</RouteContainer>
</Router>
</Provider>
);
ReactDOM.render(<Root />, document.getElementById('root'));