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
|
|
|
|
2018-06-07 13:34:12 +02:00
|
|
|
function Admin (props) {
|
|
|
|
const { user } = props
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Helmet>
|
2018-06-07 14:45:43 +02:00
|
|
|
<title>FitTrackee - Admin</title>
|
2018-06-07 13:34:12 +02:00
|
|
|
</Helmet>
|
|
|
|
{isLoggedIn() ? (
|
2018-06-12 11:47:01 +02:00
|
|
|
user.admin ? (
|
2018-06-07 13:34:12 +02:00
|
|
|
<Switch>
|
|
|
|
<Route exact path="/admin" component={AdminMenu} />
|
|
|
|
<Route exact path="/admin/sports" component={AdminSports} />
|
|
|
|
<Route
|
|
|
|
exact path="/admin/sports/add"
|
|
|
|
component={AdminSportsAdd}
|
|
|
|
/>
|
|
|
|
<Route
|
|
|
|
exact path="/admin/sports/:sportId"
|
|
|
|
component={AdminSport}
|
|
|
|
/>
|
|
|
|
<Route component={NotFound} />
|
|
|
|
</Switch>
|
|
|
|
) : (
|
|
|
|
<AccessDenied />
|
|
|
|
)
|
|
|
|
) : (<Redirect to="/login" />)}
|
|
|
|
</div>
|
|
|
|
)
|
2018-01-28 13:01:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(
|
|
|
|
state => ({
|
|
|
|
user: state.user,
|
|
|
|
})
|
|
|
|
)(Admin)
|