FitTrackee/mpwo_client/src/components/App.jsx

76 lines
1.7 KiB
React
Raw Normal View History

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'
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'
2017-12-31 18:43:24 +01:00
import Profile from './User/Profile'
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
}
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} />
2017-12-31 18:43:24 +01:00
<Route
exact path="/profile"
render={() => (
isLoggedIn() ? (
<Profile />
) : (
<UserForm
formType={'Login'}
/>
)
)}
/>
2017-12-25 18:19:28 +01:00
</Switch>
</div>
2017-12-17 11:57:05 +01:00
)
}
}