diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-08-19 15:39:58 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-23 10:05:43 +0200 |
| commit | 19033b8460cb43dc2fa34a2cffa932b5efe111ca (patch) | |
| tree | 79bde2093acce8d8192d27e288d61bc53cf99e07 /src/routes | |
| parent | 434be6d21ad665cb6abdf5138d0c563efbfe00b4 (diff) | |
Add profile page
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/index.js | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/routes/index.js b/src/routes/index.js index 6257017e..af1b70b5 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -3,19 +3,17 @@ import {BrowserRouter, Redirect, Route, Switch} from "react-router-dom"; import {userIsLoggedIn} from "../auth/index"; import Home from "../pages/Home"; import NotFound from "../pages/NotFound"; +import Profile from "../pages/Profile"; import Simulations from "../pages/Simulations"; +const ProtectedComponent = (component) => () => userIsLoggedIn() ? component : <Redirect to="/"/>; + const Routes = () => ( <BrowserRouter> <Switch> <Route exact path="/" component={Home}/> - <Route exact path="/simulations" render={() => ( - userIsLoggedIn() ? ( - <Simulations/> - ) : ( - <Redirect to="/"/> - ) - )}/> + <Route exact path="/simulations" render={ProtectedComponent(<Simulations/>)}/> + <Route exact path="/profile" render={ProtectedComponent(<Profile/>)}/> <Route path="/*" component={NotFound}/> </Switch> </BrowserRouter> |
