Showing
1 changed file
with
29 additions
and
0 deletions
front/src/Routes/Router.js
0 → 100644
1 | +import React from "react"; | ||
2 | +import PropTypes from "prop-types"; | ||
3 | +import { BrowserRouter as Router, Route, Switch } from "react-router-dom"; | ||
4 | +import Auth from "./Auth"; | ||
5 | +import Home from "./Home"; | ||
6 | + | ||
7 | +const LoggedInRoutes = () => ( | ||
8 | + <> | ||
9 | + <Route exact path="/" component={Home} /> | ||
10 | + </> | ||
11 | +); | ||
12 | + | ||
13 | +const LoggedOutRoutes = () => ( | ||
14 | + <> | ||
15 | + <Route exact path="/" component={Auth} /> | ||
16 | + </> | ||
17 | +); | ||
18 | + | ||
19 | +const AppRouter = ({ isLoggedIn }) => ( | ||
20 | + <Router> | ||
21 | + <Switch>{isLoggedIn ? <LoggedInRoutes /> : <LoggedOutRoutes />}</Switch> | ||
22 | + </Router> | ||
23 | +); | ||
24 | + | ||
25 | +AppRouter.propTypes = { | ||
26 | + isLoggedIn: PropTypes.bool.isRequired, | ||
27 | +}; | ||
28 | + | ||
29 | +export default AppRouter; |
-
Please register or login to post a comment