Client: admin menu init

This commit is contained in:
SamR1 2018-01-28 22:36:13 +01:00
parent edddfd0678
commit a23643b24d
4 changed files with 82 additions and 16 deletions

View File

@ -0,0 +1,43 @@
import React from 'react'
import { Helmet } from 'react-helmet'
import { connect } from 'react-redux'
import { Link } from 'react-router-dom'
class AdminMenu extends React.Component {
componentDidMount() {}
render() {
return (
<div>
<Helmet>
<title>mpwo - Admin</title>
</Helmet>
<h1 className="page-title">Administration</h1>
<div className="container">
<div className="row">
<div className="col-md-2" />
<div className="col-md-8 card">
<ul>
<li>
<Link
to={{
pathname: '/admin/sports',
}}
>
Sports
</Link>
</li>
</ul>
</div>
<div className="col-md-2" />
</div>
</div>
</div>
)
}
}
export default connect(
state => ({
user: state.user,
})
)(AdminMenu)

View File

@ -0,0 +1,23 @@
import React from 'react'
import { Helmet } from 'react-helmet'
import { connect } from 'react-redux'
class AdminSports extends React.Component {
componentDidMount() {}
render() {
return (
<div>
<Helmet>
<title>mpwo - Admin</title>
</Helmet>
<h1 className="page-title">Administration - Sports</h1>
</div>
)
}
}
export default connect(
state => ({
user: state.user,
})
)(AdminSports)

View File

@ -1,8 +1,13 @@
import React from 'react'
import { Helmet } from 'react-helmet'
import { connect } from 'react-redux'
import { Redirect, Route, Switch } from 'react-router-dom'
import AdminMenu from './AdminMenu'
import AdminSports from './AdminSports'
import AccessDenied from './../Others/AccessDenied'
import NotFound from './../Others/NotFound'
import { isLoggedIn } from '../../utils'
class Admin extends React.Component {
componentDidMount() {}
@ -13,11 +18,17 @@ class Admin extends React.Component {
<Helmet>
<title>mpwo - Admin</title>
</Helmet>
{!user.isAdmin ? (
{isLoggedIn() ? (
user.isAdmin ? (
<Switch>
<Route exact path="/admin" component={AdminMenu} />
<Route path="/admin/sports" component={AdminSports} />
<Route component={NotFound} />
</Switch>
) : (
<AccessDenied />
) : (
<h1 className="page-title">Admin</h1>
)}
)
) : (<Redirect to="/login" />)}
</div>
)
}

View File

@ -83,18 +83,7 @@ export default class App extends React.Component {
)
)}
/>
<Route
exact path="/admin"
render={() => (
isLoggedIn() ? (
<Admin />
) : (
<UserForm
formType={'Login'}
/>
)
)}
/>
<Route path="/admin" component={Admin} />
<Route component={NotFound} />
</Switch>
</div>