2018-09-17 13:55:49 -07:00
|
|
|
import React from 'react';
|
|
|
|
import { hot } from 'react-hot-loader';
|
2018-09-27 20:03:53 -07:00
|
|
|
import { Switch, Route } from 'react-router';
|
2018-09-17 13:55:49 -07:00
|
|
|
import loadable from 'loadable-components';
|
2018-10-01 14:01:20 -07:00
|
|
|
import AuthRoute from 'components/AuthRoute';
|
2018-09-17 13:55:49 -07:00
|
|
|
|
|
|
|
// wrap components in loadable...import & they will be split
|
|
|
|
const Home = loadable(() => import('pages/index'));
|
|
|
|
const Create = loadable(() => import('pages/create'));
|
|
|
|
const Proposals = loadable(() => import('pages/proposals'));
|
|
|
|
const Proposal = loadable(() => import('pages/proposal'));
|
2018-10-01 14:01:20 -07:00
|
|
|
const Auth = loadable(() => import('pages/auth'));
|
|
|
|
const Profile = loadable(() => import('pages/profile'));
|
2018-09-27 20:03:53 -07:00
|
|
|
const Exception = loadable(() => import('pages/exception'));
|
2018-09-17 13:55:49 -07:00
|
|
|
|
|
|
|
import 'styles/style.less';
|
|
|
|
|
|
|
|
class Routes extends React.Component<any> {
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Switch>
|
|
|
|
<Route exact path="/" component={Home} />
|
|
|
|
<Route path="/create" component={Create} />
|
|
|
|
<Route exact path="/proposals" component={Proposals} />
|
|
|
|
<Route path="/proposals/:id" component={Proposal} />
|
2018-10-01 14:01:20 -07:00
|
|
|
<AuthRoute exact path="/profile" component={Profile} />
|
2018-10-03 10:11:44 -07:00
|
|
|
<Route path="/profile/:id" component={Profile} />
|
2018-10-01 14:01:20 -07:00
|
|
|
<AuthRoute path="/auth" component={Auth} onlyLoggedOut />
|
2018-09-27 20:03:53 -07:00
|
|
|
<Route path="/*" render={() => <Exception type="404" />} />
|
2018-09-17 13:55:49 -07:00
|
|
|
</Switch>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default hot(module)(Routes);
|