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 React from 'react'
|
||||||
import { Helmet } from 'react-helmet'
|
import { Helmet } from 'react-helmet'
|
||||||
import { connect } from 'react-redux'
|
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 AccessDenied from './../Others/AccessDenied'
|
||||||
|
import NotFound from './../Others/NotFound'
|
||||||
|
import { isLoggedIn } from '../../utils'
|
||||||
|
|
||||||
class Admin extends React.Component {
|
class Admin extends React.Component {
|
||||||
componentDidMount() {}
|
componentDidMount() {}
|
||||||
@ -13,11 +18,17 @@ class Admin extends React.Component {
|
|||||||
<Helmet>
|
<Helmet>
|
||||||
<title>mpwo - Admin</title>
|
<title>mpwo - Admin</title>
|
||||||
</Helmet>
|
</Helmet>
|
||||||
{!user.isAdmin ? (
|
{isLoggedIn() ? (
|
||||||
|
user.isAdmin ? (
|
||||||
|
<Switch>
|
||||||
|
<Route exact path="/admin" component={AdminMenu} />
|
||||||
|
<Route path="/admin/sports" component={AdminSports} />
|
||||||
|
<Route component={NotFound} />
|
||||||
|
</Switch>
|
||||||
|
) : (
|
||||||
<AccessDenied />
|
<AccessDenied />
|
||||||
) : (
|
)
|
||||||
<h1 className="page-title">Admin</h1>
|
) : (<Redirect to="/login" />)}
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -83,18 +83,7 @@ export default class App extends React.Component {
|
|||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route path="/admin" component={Admin} />
|
||||||
exact path="/admin"
|
|
||||||
render={() => (
|
|
||||||
isLoggedIn() ? (
|
|
||||||
<Admin />
|
|
||||||
) : (
|
|
||||||
<UserForm
|
|
||||||
formType={'Login'}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<Route component={NotFound} />
|
<Route component={NotFound} />
|
||||||
</Switch>
|
</Switch>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user