FitTrackee/mpwo_client/src/components/Admin/index.jsx

44 lines
1.1 KiB
React
Raw Normal View History

2018-01-28 13:01:26 +01:00
import React from 'react'
import { Helmet } from 'react-helmet'
import { connect } from 'react-redux'
2018-01-28 22:36:13 +01:00
import { Redirect, Route, Switch } from 'react-router-dom'
2018-01-28 13:01:26 +01:00
2018-01-28 22:36:13 +01:00
import AdminMenu from './AdminMenu'
2018-04-30 20:08:18 +02:00
import AdminSport from './AdminSport'
2018-01-28 22:36:13 +01:00
import AdminSports from './AdminSports'
2018-01-28 13:01:26 +01:00
import AccessDenied from './../Others/AccessDenied'
2018-01-28 22:36:13 +01:00
import NotFound from './../Others/NotFound'
import { isLoggedIn } from '../../utils'
2018-01-28 13:01:26 +01:00
class Admin extends React.Component {
componentDidMount() {}
render() {
const { user } = this.props
return (
<div>
<Helmet>
<title>mpwo - Admin</title>
</Helmet>
2018-01-28 22:36:13 +01:00
{isLoggedIn() ? (
user.isAdmin ? (
<Switch>
<Route exact path="/admin" component={AdminMenu} />
2018-04-30 20:08:18 +02:00
<Route exact path="/admin/sports" component={AdminSports} />
<Route path="/admin/sport" component={AdminSport} />
2018-01-28 22:36:13 +01:00
<Route component={NotFound} />
</Switch>
) : (
2018-01-28 13:01:26 +01:00
<AccessDenied />
2018-01-28 22:36:13 +01:00
)
) : (<Redirect to="/login" />)}
2018-01-28 13:01:26 +01:00
</div>
)
}
}
export default connect(
state => ({
user: state.user,
})
)(Admin)