58 lines
1.7 KiB
JavaScript
58 lines
1.7 KiB
JavaScript
import React from 'react';
|
|
import { Router, Route, Redirect, IndexRoute, useRouterHistory } from 'react-router';
|
|
import { createHistory } from 'history';
|
|
|
|
import LoadingScreen from '/imports/ui/components/loading-screen/component';
|
|
import ChatContainer from '/imports/ui/components/chat/container';
|
|
import UserListContainer from '/imports/ui/components/user-list/container';
|
|
import { joinRouteHandler, logoutRouteHandler, authenticatedRouteHandler } from './auth';
|
|
import Base from './base';
|
|
|
|
const browserHistory = useRouterHistory(createHistory)({
|
|
basename: Meteor.settings.public.app.basename,
|
|
});
|
|
|
|
const disconnect = () => {
|
|
Meteor.disconnect();
|
|
};
|
|
|
|
const renderRoutes = () => (
|
|
<Router history={browserHistory} >
|
|
<Route path="/logout" onEnter={logoutRouteHandler} />
|
|
<Route
|
|
path="/join"
|
|
component={LoadingScreen}
|
|
onEnter={joinRouteHandler}
|
|
/>
|
|
<Route path="/" component={Base} onEnter={authenticatedRouteHandler} >
|
|
<IndexRoute components={{}} />
|
|
<Route name="users" path="users" components={{ userList: UserListContainer }} />
|
|
<Route
|
|
name="chat"
|
|
path="users/chat/:chatID"
|
|
components={{
|
|
userList: UserListContainer,
|
|
chat: ChatContainer,
|
|
}}
|
|
/>
|
|
<Redirect from="users/chat" to="/users/chat/public" />
|
|
</Route>
|
|
<Route
|
|
name="meeting-ended"
|
|
path="/ended/:endedCode"
|
|
component={Base}
|
|
onEnter={disconnect}
|
|
onLeave={logoutRouteHandler}
|
|
/>
|
|
<Route
|
|
name="error"
|
|
path="/error/:errorCode"
|
|
component={Base}
|
|
onEnter={disconnect}
|
|
/>
|
|
<Redirect from="*" to="/error/404" />
|
|
</Router>
|
|
);
|
|
|
|
export default renderRoutes;
|