2016-04-29 03:02:51 +08:00
|
|
|
import React from 'react';
|
2016-07-08 20:22:49 +08:00
|
|
|
import { Router, Route, Redirect, IndexRoute, useRouterHistory } from 'react-router';
|
2016-05-10 03:19:52 +08:00
|
|
|
import { createHistory } from 'history';
|
2016-04-29 03:02:51 +08:00
|
|
|
|
2017-03-17 22:23:00 +08:00
|
|
|
import { joinRouteHandler, logoutRouteHandler, authenticatedRouteHandler } from './auth';
|
2017-03-10 03:50:21 +08:00
|
|
|
import Base from './base';
|
2016-06-02 00:45:01 +08:00
|
|
|
|
2017-03-11 02:33:46 +08:00
|
|
|
import LoadingScreen from '/imports/ui/components/loading-screen/component';
|
2016-07-07 22:01:40 +08:00
|
|
|
import ChatContainer from '/imports/ui/components/chat/container';
|
|
|
|
import UserListContainer from '/imports/ui/components/user-list/container';
|
2016-04-29 03:02:51 +08:00
|
|
|
|
2016-05-10 03:19:52 +08:00
|
|
|
const browserHistory = useRouterHistory(createHistory)({
|
2016-08-17 23:48:03 +08:00
|
|
|
basename: Meteor.settings.public.app.basename,
|
2016-05-10 03:19:52 +08:00
|
|
|
});
|
2016-05-07 03:12:28 +08:00
|
|
|
|
2016-04-29 03:02:51 +08:00
|
|
|
export const renderRoutes = () => (
|
|
|
|
<Router history={browserHistory}>
|
2017-03-17 22:23:00 +08:00
|
|
|
<Route path="/logout" onEnter={logoutRouteHandler} />
|
2017-06-03 03:25:02 +08:00
|
|
|
<Route
|
2017-06-09 23:56:30 +08:00
|
|
|
path="/join"
|
2017-09-07 03:36:52 +08:00
|
|
|
component={LoadingScreen}
|
|
|
|
onEnter={joinRouteHandler}
|
2017-06-03 03:25:02 +08:00
|
|
|
/>
|
2017-03-11 02:33:46 +08:00
|
|
|
<Route path="/" component={Base} onEnter={authenticatedRouteHandler} >
|
2016-07-06 02:59:18 +08:00
|
|
|
<IndexRoute components={{}} />
|
2017-03-10 03:50:21 +08:00
|
|
|
<Route name="users" path="users" components={{ userList: UserListContainer }} />
|
2017-06-03 03:25:02 +08:00
|
|
|
<Route
|
2017-09-07 03:36:52 +08:00
|
|
|
name="chat"
|
|
|
|
path="users/chat/:chatID"
|
|
|
|
components={{
|
2017-06-03 03:25:02 +08:00
|
|
|
userList: UserListContainer,
|
|
|
|
chat: ChatContainer,
|
|
|
|
}}
|
|
|
|
/>
|
2016-07-06 02:59:18 +08:00
|
|
|
<Redirect from="users/chat" to="/users/chat/public" />
|
2016-04-29 03:02:51 +08:00
|
|
|
</Route>
|
2017-06-03 03:25:02 +08:00
|
|
|
<Route name="error" path="/error/:errorCode" component={Base} />
|
2017-03-11 04:47:23 +08:00
|
|
|
<Redirect from="*" to="/error/404" />
|
2016-04-29 03:02:51 +08:00
|
|
|
</Router>
|
|
|
|
);
|