From a16bc79756e315a8551125b448d1ba3bf2a09ea1 Mon Sep 17 00:00:00 2001 From: Markus Schubert Date: Mon, 30 Mar 2020 14:55:52 +0200 Subject: [PATCH] add link to public states on admin dashboard --- client/src/components/AppHeader/AppHeader.js | 25 ++++++++++++++----- .../PublicStateList/PublicStateList.js | 9 ++++--- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/client/src/components/AppHeader/AppHeader.js b/client/src/components/AppHeader/AppHeader.js index 2ca198c..5e89fd4 100644 --- a/client/src/components/AppHeader/AppHeader.js +++ b/client/src/components/AppHeader/AppHeader.js @@ -38,7 +38,8 @@ class AppHeader extends Component { super(props); this.state = { logoutSuccess: false, - redirectToStart: false + redirectToStart: false, + redirectToAdmin: false } } @@ -53,11 +54,15 @@ class AppHeader extends Component { console.log('error logging out: ' + error); }); break; - case 'start': - this.setState({ - redirectToStart: true - }); - break; + case 'start': + this.setState({ + redirectToStart: true + }); + break; + case 'admin': + this.setState({ + redirectToAdmin: true + }); default: break; } @@ -73,6 +78,12 @@ class AppHeader extends Component { const redirectAfterLogout = this.state.logoutSuccess ? :
const redirectToStart = this.state.redirectToStart ? :
+ const redirectToAdmin = this.state.redirectToAdmin ? :
+ + let adminSubmenu; + if (this.props.user && this.props.user.role === 'admin') { + adminSubmenu = admin + } if (this.props.user) { userInfo = ( @@ -86,6 +97,7 @@ class AppHeader extends Component { }> start + {adminSubmenu} logout @@ -96,6 +108,7 @@ class AppHeader extends Component {
{redirectAfterLogout} {redirectToStart} + {redirectToAdmin}
Die Gesellschaft der Gegenwart diff --git a/client/src/components/PublicStateList/PublicStateList.js b/client/src/components/PublicStateList/PublicStateList.js index aeb5515..c33e4ff 100644 --- a/client/src/components/PublicStateList/PublicStateList.js +++ b/client/src/components/PublicStateList/PublicStateList.js @@ -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 ( -
{ps.name}
+
+ + {ps.name} + +
) });