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

43 lines
1.2 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
2019-08-28 15:35:22 +02:00
function Admin(props) {
2018-06-07 13:34:12 +02:00
const { user } = props
return (
<div>
<Helmet>
<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} />
2019-08-28 15:35:22 +02:00
<Route exact path="/admin/sports/add" component={AdminSportsAdd} />
<Route exact path="/admin/sports/:sportId" component={AdminSport} />
2018-06-07 13:34:12 +02:00
<Route component={NotFound} />
</Switch>
) : (
<AccessDenied />
)
2019-08-28 15:35:22 +02:00
) : (
<Redirect to="/login" />
)}
2018-06-07 13:34:12 +02:00
</div>
)
2018-01-28 13:01:26 +01:00
}
2019-08-28 15:35:22 +02:00
export default connect(state => ({
user: state.user,
}))(Admin)