2017-12-17 11:57:05 +01:00
|
|
|
import React from 'react'
|
2017-12-25 20:11:10 +01:00
|
|
|
import { Redirect, Route, Switch } from 'react-router-dom'
|
2017-12-17 11:57:05 +01:00
|
|
|
|
|
|
|
import './App.css'
|
2018-01-28 13:01:26 +01:00
|
|
|
import Admin from './Admin'
|
2018-05-01 19:29:21 +02:00
|
|
|
import AddWorkout from './Activities/AddActivity'
|
2017-12-25 18:19:28 +01:00
|
|
|
import Dashboard from './Dashboard'
|
2017-12-31 18:43:24 +01:00
|
|
|
import Logout from './User/Logout'
|
2017-12-17 12:27:07 +01:00
|
|
|
import NavBar from './NavBar'
|
2018-01-28 13:01:26 +01:00
|
|
|
import NotFound from './Others/NotFound'
|
2017-12-31 18:43:24 +01:00
|
|
|
import Profile from './User/Profile'
|
2018-01-01 16:59:46 +01:00
|
|
|
import ProfileEdit from './User/ProfileEdit'
|
2017-12-25 17:45:28 +01:00
|
|
|
import UserForm from './User/UserForm'
|
2017-12-25 20:11:10 +01:00
|
|
|
import { isLoggedIn } from '../utils'
|
2017-12-17 11:57:05 +01:00
|
|
|
|
2017-12-17 12:27:07 +01:00
|
|
|
export default class App extends React.Component {
|
2017-12-25 20:11:10 +01:00
|
|
|
|
2017-12-17 11:57:05 +01:00
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
|
|
|
this.props = props
|
|
|
|
}
|
2017-12-17 09:46:40 +01:00
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div className="App">
|
2017-12-17 12:27:07 +01:00
|
|
|
<NavBar />
|
2017-12-25 18:19:28 +01:00
|
|
|
<Switch>
|
2017-12-25 20:11:10 +01:00
|
|
|
<Route
|
|
|
|
exact path="/"
|
|
|
|
render={() => (
|
|
|
|
isLoggedIn() ? (
|
|
|
|
<Dashboard />
|
|
|
|
) : (
|
|
|
|
<Redirect to="/login" />
|
|
|
|
)
|
|
|
|
)}
|
|
|
|
/>
|
2017-12-25 18:19:28 +01:00
|
|
|
<Route
|
|
|
|
exact path="/register"
|
|
|
|
render={() => (
|
2017-12-25 20:11:10 +01:00
|
|
|
isLoggedIn() ? (
|
|
|
|
<Redirect to="/" />
|
|
|
|
) : (
|
|
|
|
<UserForm
|
|
|
|
formType={'Register'}
|
|
|
|
/>
|
|
|
|
)
|
2017-12-25 18:19:28 +01:00
|
|
|
)}
|
|
|
|
/>
|
|
|
|
<Route
|
|
|
|
exact path="/login"
|
|
|
|
render={() => (
|
2017-12-25 20:11:10 +01:00
|
|
|
isLoggedIn() ? (
|
|
|
|
<Redirect to="/" />
|
|
|
|
) : (
|
|
|
|
<UserForm
|
|
|
|
formType={'Login'}
|
|
|
|
/>
|
|
|
|
)
|
2017-12-25 18:19:28 +01:00
|
|
|
)}
|
|
|
|
/>
|
|
|
|
<Route exact path="/logout" component={Logout} />
|
2018-01-01 16:59:46 +01:00
|
|
|
<Route
|
|
|
|
exact path="/profile/edit"
|
|
|
|
render={() => (
|
|
|
|
isLoggedIn() ? (
|
|
|
|
<ProfileEdit />
|
|
|
|
) : (
|
|
|
|
<UserForm
|
|
|
|
formType={'Login'}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
)}
|
|
|
|
/>
|
2017-12-31 18:43:24 +01:00
|
|
|
<Route
|
|
|
|
exact path="/profile"
|
|
|
|
render={() => (
|
|
|
|
isLoggedIn() ? (
|
|
|
|
<Profile />
|
|
|
|
) : (
|
|
|
|
<UserForm
|
|
|
|
formType={'Login'}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
)}
|
|
|
|
/>
|
2018-05-01 19:29:21 +02:00
|
|
|
<Route exact path="/activities/add" component={AddWorkout} />
|
2018-01-28 22:36:13 +01:00
|
|
|
<Route path="/admin" component={Admin} />
|
2017-12-31 19:32:52 +01:00
|
|
|
<Route component={NotFound} />
|
2017-12-25 18:19:28 +01:00
|
|
|
</Switch>
|
|
|
|
</div>
|
2017-12-17 11:57:05 +01:00
|
|
|
)
|
2017-12-17 09:46:40 +01:00
|
|
|
}
|
|
|
|
}
|