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

52 lines
1.4 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-04-30 21:38:09 +02:00
import AdminMenu from './Sports/AdminMenu'
import AdminSport from './Sports/AdminSport'
import AdminSports from './Sports/AdminSports'
2018-05-01 12:40:30 +02:00
import AdminSportsAdd from './Sports/AdminSportsAdd'
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} />
2018-05-01 12:40:30 +02:00
<Route
exact path="/admin/sports/add"
component={AdminSportsAdd}
/>
2018-05-10 20:17:03 +02:00
<Route
exact path="/admin/sports/:sportId"
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)