add link to public states on admin dashboard
This commit is contained in:
parent
4639eade8d
commit
a16bc79756
2 changed files with 25 additions and 9 deletions
|
@ -38,7 +38,8 @@ class AppHeader extends Component {
|
|||
super(props);
|
||||
this.state = {
|
||||
logoutSuccess: false,
|
||||
redirectToStart: false
|
||||
redirectToStart: false,
|
||||
redirectToAdmin: false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,6 +59,10 @@ class AppHeader extends Component {
|
|||
redirectToStart: true
|
||||
});
|
||||
break;
|
||||
case 'admin':
|
||||
this.setState({
|
||||
redirectToAdmin: true
|
||||
});
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -73,6 +78,12 @@ class AppHeader extends Component {
|
|||
|
||||
const redirectAfterLogout = this.state.logoutSuccess ? <Redirect to='/login' /> : <div></div>
|
||||
const redirectToStart = this.state.redirectToStart ? <Redirect to='/start' /> : <div></div>
|
||||
const redirectToAdmin = this.state.redirectToAdmin ? <Redirect to='/admin' /> : <div></div>
|
||||
|
||||
let adminSubmenu;
|
||||
if (this.props.user && this.props.user.role === 'admin') {
|
||||
adminSubmenu = <Menu.Item key='admin'>admin</Menu.Item>
|
||||
}
|
||||
|
||||
if (this.props.user) {
|
||||
userInfo = (
|
||||
|
@ -86,6 +97,7 @@ class AppHeader extends Component {
|
|||
</span>
|
||||
}>
|
||||
<Menu.Item key="start">start</Menu.Item>
|
||||
{adminSubmenu}
|
||||
<Menu.Item key="logout">logout</Menu.Item>
|
||||
</SubMenu>
|
||||
</Menu>
|
||||
|
@ -96,6 +108,7 @@ class AppHeader extends Component {
|
|||
<Header style={{ position: 'fixed', zIndex: 1, width: '100%', background: '#3399cc' }}>
|
||||
{redirectAfterLogout}
|
||||
{redirectToStart}
|
||||
{redirectToAdmin}
|
||||
<div style={styles.logo}>
|
||||
<img style={styles.logoImage} src='images/logo.png' alt='' />
|
||||
<Link style={styles.logo} to="/">Die Gesellschaft der Gegenwart</Link>
|
||||
|
|
|
@ -2,6 +2,7 @@ import React, { Component } from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
import { loadPublicStates } from '../../actions/gameActions';
|
||||
import { connect } from 'react-redux';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
class PublicStateList extends Component {
|
||||
|
||||
|
@ -11,11 +12,13 @@ class PublicStateList extends Component {
|
|||
|
||||
render() {
|
||||
|
||||
console.log('public states: ' + this.props.publicStates);
|
||||
|
||||
const pubStateList = this.props.publicStates.map((ps) => {
|
||||
return (
|
||||
<div key={ps.id}>{ps.name}</div>
|
||||
<div key={ps.id}>
|
||||
<Link to={"/state/" + ps.name}>
|
||||
{ps.name}
|
||||
</Link>
|
||||
</div>
|
||||
)
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue