diff options
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> |
