-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
49 lines (41 loc) · 1.43 KB
/
App.js
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
import React, { useEffect } from 'react';
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom';
import { connect } from 'react-redux';
import 'antd/dist/antd.css';
import * as actions from './store/actions/user';
import CustomLayout from './containers/Layout';
import Login from './components/Login';
import MyProfile from './components/MyProfile/index';
import Errors from './containers/Errors/Error';
const App = (props) => {
useEffect(() => {
props.autologin();
})
return (
<div>
<Router>
<Switch>
<Route exact path='/login/' component={Login} />
{/* Signup is the same page as success because due to this method of authentification registering is not required
but it will be implemented anyways as visitors may not know this */}
<Route exact path='/signup/' render={() => <Login formTitle="Register" formSuccessTitle="Register Success" />} />
<Route path='/error/' component={Errors} />
<CustomLayout {...props}>
<Route path='/my_profile/' component={MyProfile} />
</CustomLayout>
</Switch>
</Router>
</div>
);
}
const mapStateToProps = state => {
return {
isAuthenticated: state.user.payload.token !== null
}
}
const mapDispatchToProps = dispatch => {
return {
autologin: () => dispatch(actions.authCheckState())
}
}
export default connect(mapStateToProps, mapDispatchToProps)(App);