-
Notifications
You must be signed in to change notification settings - Fork 171
/
routes.js
37 lines (33 loc) · 1.2 KB
/
routes.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
import { connectedRouterRedirect } from 'redux-auth-wrapper/history4/redirect';
import { App, Home, NotFound } from 'containers';
import About from 'containers/About/Loadable';
import Chat from 'containers/Chat/Loadable';
import Login from 'containers/Login/Loadable';
import LoginSuccess from 'containers/LoginSuccess/Loadable';
import Register from 'containers/Register/Loadable';
const isAuthenticated = connectedRouterRedirect({
redirectPath: '/login',
authenticatedSelector: state => state.auth.user !== null,
wrapperDisplayName: 'UserIsAuthenticated'
});
const isNotAuthenticated = connectedRouterRedirect({
redirectPath: '/',
authenticatedSelector: state => state.auth.user === null,
wrapperDisplayName: 'UserIsAuthenticated',
allowRedirectBack: false
});
const routes = [
{
component: App,
routes: [
{ path: '/', exact: true, component: Home },
{ path: '/about', component: About },
{ path: '/chat', component: Chat },
{ path: '/login', component: Login },
{ path: '/login-success', component: isAuthenticated(LoginSuccess) },
{ path: '/register', component: isNotAuthenticated(Register) },
{ component: NotFound }
]
}
];
export default routes;