summaryrefslogtreecommitdiff
path: root/frontend/src/routes
diff options
context:
space:
mode:
authorGeorgios Andreadis <info@gandreadis.com>2020-07-02 18:39:28 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-08-24 19:47:21 +0200
commitf119fc78dda4d1e828dde04f378a63a93e3a0a7e (patch)
treebea1eace5d47f21a7ccb835c6a6079bc92e48710 /frontend/src/routes
parent7f27a6370a0af25e1bf6ff8f46360c6c26c21e0b (diff)
Add current progress on frontend port
Diffstat (limited to 'frontend/src/routes')
-rw-r--r--frontend/src/routes/index.js49
1 files changed, 12 insertions, 37 deletions
diff --git a/frontend/src/routes/index.js b/frontend/src/routes/index.js
index 119cdb54..ea703567 100644
--- a/frontend/src/routes/index.js
+++ b/frontend/src/routes/index.js
@@ -8,55 +8,30 @@ import NotFound from '../pages/NotFound'
import Profile from '../pages/Profile'
import Simulations from '../pages/Simulations'
-const ProtectedComponent = component => () =>
- userIsLoggedIn() ? component : <Redirect to="/"/>
+const ProtectedComponent = (component) => () => (userIsLoggedIn() ? component : <Redirect to="/" />)
const AppComponent = ({ match }) =>
- userIsLoggedIn() ? (
- <App simulationId={parseInt(match.params.simulationId, 10)}/>
- ) : (
- <Redirect to="/"/>
- )
+ userIsLoggedIn() ? <App simulationId={match.params.simulationId} /> : <Redirect to="/" />
const ExperimentsComponent = ({ match }) =>
- userIsLoggedIn() ? (
- <Experiments simulationId={parseInt(match.params.simulationId, 10)}/>
- ) : (
- <Redirect to="/"/>
- )
+ userIsLoggedIn() ? <Experiments simulationId={match.params.simulationId} /> : <Redirect to="/" />
const SimulationComponent = ({ match }) =>
userIsLoggedIn() ? (
- <App
- simulationId={parseInt(match.params.simulationId, 10)}
- inSimulation={true}
- experimentId={parseInt(match.params.experimentId, 10)}
- />
+ <App simulationId={match.params.simulationId} inSimulation={true} experimentId={match.params.experimentId} />
) : (
- <Redirect to="/"/>
+ <Redirect to="/" />
)
const Routes = () => (
<BrowserRouter>
<Switch>
- <Route exact path="/" component={Home}/>
- <Route
- exact
- path="/simulations"
- render={ProtectedComponent(<Simulations/>)}
- />
- <Route exact path="/simulations/:simulationId" component={AppComponent}/>
- <Route
- exact
- path="/simulations/:simulationId/experiments"
- component={ExperimentsComponent}
- />
- <Route
- exact
- path="/simulations/:simulationId/experiments/:experimentId"
- component={SimulationComponent}
- />
- <Route exact path="/profile" render={ProtectedComponent(<Profile/>)}/>
- <Route path="/*" component={NotFound}/>
+ <Route exact path="/" component={Home} />
+ <Route exact path="/simulations" render={ProtectedComponent(<Simulations />)} />
+ <Route exact path="/simulations/:simulationId" component={AppComponent} />
+ <Route exact path="/simulations/:simulationId/experiments" component={ExperimentsComponent} />
+ <Route exact path="/simulations/:simulationId/experiments/:experimentId" component={SimulationComponent} />
+ <Route exact path="/profile" render={ProtectedComponent(<Profile />)} />
+ <Route path="/*" component={NotFound} />
</Switch>
</BrowserRouter>
)