Remove the edit button from tournaments that the user is not the owner of
This commit is contained in:
parent
7c40ba0e61
commit
4dc55a93d2
|
|
@ -22,6 +22,7 @@ import 'bootstrap/dist/css/bootstrap.min.css';
|
||||||
import {BigImage, Footer, TurniereNavigation} from '../js/CommonComponents.js';
|
import {BigImage, Footer, TurniereNavigation} from '../js/CommonComponents.js';
|
||||||
import '../static/everypage.css';
|
import '../static/everypage.css';
|
||||||
import '../static/css/tournament.css';
|
import '../static/css/tournament.css';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getRequest,
|
getRequest,
|
||||||
|
|
@ -38,7 +39,7 @@ class TournamentPage extends React.Component {
|
||||||
return (
|
return (
|
||||||
<div className='pb-5'>
|
<div className='pb-5'>
|
||||||
<Container>
|
<Container>
|
||||||
<a href={'/t/' + id + '/edit'} className='btn btn-outline-secondary'>Turnier bearbeiten</a>
|
<EditButton id={id} ownerName={ownerUsername}/>
|
||||||
<p>{description}</p>
|
<p>{description}</p>
|
||||||
<ListGroup>
|
<ListGroup>
|
||||||
<ListGroupItem>
|
<ListGroupItem>
|
||||||
|
|
@ -57,6 +58,27 @@ class TournamentPage extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function PrivateEditButton(props) {
|
||||||
|
const { id, ownerName, isSignedIn, username } = props;
|
||||||
|
|
||||||
|
if(isSignedIn && ownerName === username) {
|
||||||
|
return (
|
||||||
|
<a href={'/t/' + id + '/edit'} className='btn btn-outline-secondary'>Turnier bearbeiten</a>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapStateToEditButtonProperties(state) {
|
||||||
|
const { isSignedIn, username } = state.userinfo;
|
||||||
|
return { isSignedIn, username };
|
||||||
|
}
|
||||||
|
|
||||||
|
const EditButton = connect(
|
||||||
|
mapStateToEditButtonProperties
|
||||||
|
)(PrivateEditButton);
|
||||||
|
|
||||||
function getLevelName(levelNumber) {
|
function getLevelName(levelNumber) {
|
||||||
const names = ['Finale', 'Halbfinale', 'Viertelfinale', 'Achtelfinale'];
|
const names = ['Finale', 'Halbfinale', 'Viertelfinale', 'Achtelfinale'];
|
||||||
if(levelNumber < names.length){
|
if(levelNumber < names.length){
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue