Client: admin menu init
This commit is contained in:
parent
edddfd0678
commit
a23643b24d
43
mpwo_client/src/components/Admin/AdminMenu.jsx
Normal file
43
mpwo_client/src/components/Admin/AdminMenu.jsx
Normal 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)
|
23
mpwo_client/src/components/Admin/AdminSports.jsx
Normal file
23
mpwo_client/src/components/Admin/AdminSports.jsx
Normal 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)
|
@ -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>
|
||||
)
|
||||
}
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user