Router.js
1.02 KB
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 React from "react";
import PropTypes from "prop-types";
import { Route, Switch } from "react-router-dom";
import Auth from "./Auth/AuthContainer";
import About from "./About";
import Main from "./MainPresenter";
import Forum from "./Forum/ForumPresenter";
import Features from "./Features";
import News from "./News";
import Chat from "./Chat/ChatContainer";
const LoggedInRoutes = () => (
<Switch>
<Route exact path="/" component={Main} />
<Route path="/chat" component={Chat} />
</Switch>
);
const LoggedOutRoutes = () => (
<Switch>
<Route exact path="/" component={Main} />
<Route path="/about" component={About} />
<Route path="/auth" component={Auth} />
<Route path="/forum" component={Forum} />
<Route path="/features" component={Features} />
<Route path="/news" component={News} />
</Switch>
);
const AppRouter = ({ isLoggedIn }) =>
isLoggedIn ? <LoggedInRoutes /> : <LoggedOutRoutes />;
AppRouter.propTypes = {
isLoggedIn: PropTypes.bool.isRequired,
};
export default AppRouter;