Add several restrictions to the edit tournament page
This commit is contained in:
parent
110f862bc3
commit
8796bbf553
|
|
@ -57,6 +57,7 @@ const defaultstate_tournamentinfo = {
|
||||||
description : '',
|
description : '',
|
||||||
id : -1,
|
id : -1,
|
||||||
name : '',
|
name : '',
|
||||||
|
ownerUsername : '',
|
||||||
isPublic : '',
|
isPublic : '',
|
||||||
stages: [],
|
stages: [],
|
||||||
teams : []
|
teams : []
|
||||||
|
|
@ -272,6 +273,7 @@ const reducer_tournamentinfo = (state = defaultstate_tournamentinfo, action) =>
|
||||||
description : action.parameters.description,
|
description : action.parameters.description,
|
||||||
id : action.parameters.id,
|
id : action.parameters.id,
|
||||||
name : action.parameters.name,
|
name : action.parameters.name,
|
||||||
|
ownerUsername : action.parameters.owner_username,
|
||||||
isPublic : action.parameters.public,
|
isPublic : action.parameters.public,
|
||||||
stages: action.parameters.stages,
|
stages: action.parameters.stages,
|
||||||
teams : action.parameters.teams
|
teams : action.parameters.teams
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { connect } from 'react-redux';
|
||||||
import { notify } from 'react-notify-toast';
|
import { notify } from 'react-notify-toast';
|
||||||
|
|
||||||
import { requestTournament } from '../js/api';
|
import { requestTournament } from '../js/api';
|
||||||
import { BigImage, Footer, TurniereNavigation } from '../js/CommonComponents.js';
|
import { BigImage, Footer, TurniereNavigation, Login, UserRestrictor, Option } from '../js/CommonComponents.js';
|
||||||
import { ErrorPageComponent } from '../js/components/ErrorComponents.js';
|
import { ErrorPageComponent } from '../js/components/ErrorComponents.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|
@ -42,7 +42,10 @@ class EditTournamentPage extends React.Component {
|
||||||
verifyCredentials();
|
verifyCredentials();
|
||||||
requestTournament(this.props.query.code, () => {
|
requestTournament(this.props.query.code, () => {
|
||||||
this.setState({ validCode: true });
|
this.setState({ validCode: true });
|
||||||
this._edittournamentcontent.notifyOfContentUpdate();
|
|
||||||
|
if(this._edittournamentcontent != null) {
|
||||||
|
this._edittournamentcontent.notifyOfContentUpdate();
|
||||||
|
}
|
||||||
}, () => {
|
}, () => {
|
||||||
this.setState({ validCode: false });
|
this.setState({ validCode: false });
|
||||||
});
|
});
|
||||||
|
|
@ -50,33 +53,60 @@ class EditTournamentPage extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { validCode } = this.state;
|
const { validCode } = this.state;
|
||||||
const { name } = this.props;
|
const { tournamentname, ownerUsername, isSignedIn, username } = this.props;
|
||||||
|
|
||||||
if(validCode) {
|
return (
|
||||||
return (
|
<UserRestrictor>
|
||||||
<div className='pb-5'>
|
<Option condition={ validCode && isSignedIn && ownerUsername === username }>
|
||||||
<Head>
|
<div className='pb-5'>
|
||||||
<title>Turnie.re - Turnier bearbeiten</title>
|
<Head>
|
||||||
</Head>
|
<title>Turnie.re - Turnier bearbeiten</title>
|
||||||
<TurniereNavigation/>
|
</Head>
|
||||||
<BigImage text={ name }/>
|
<TurniereNavigation/>
|
||||||
|
|
||||||
<EditTournamentContent ref={(edittournamentcontent) => { this._edittournamentcontent = edittournamentcontent; }}/>
|
<BigImage text={ tournamentname }/>
|
||||||
|
<EditTournamentContent ref={(edittournamentcontent) => { this._edittournamentcontent = edittournamentcontent; }}/>
|
||||||
<Footer/>
|
<Footer/>
|
||||||
</div>
|
</div>
|
||||||
);
|
</Option>
|
||||||
} else {
|
<Option condition={ validCode && isSignedIn }>
|
||||||
return (
|
<div className='pb-5'>
|
||||||
<ErrorPageComponent statusCode={ 404 }/>
|
<Head>
|
||||||
);
|
<title>Turnie.re - Turnier bearbeiten</title>
|
||||||
}
|
</Head>
|
||||||
|
<TurniereNavigation/>
|
||||||
|
|
||||||
|
<BigImage text="TODO: Not allowed to edit tournament"/>
|
||||||
|
|
||||||
|
<Footer/>
|
||||||
|
</div>
|
||||||
|
</Option>
|
||||||
|
<Option condition={ validCode }>
|
||||||
|
<div className="main generic-fullpage-bg">
|
||||||
|
<Head>
|
||||||
|
<title>Turnie.re - Turnier bearbeiten</title>
|
||||||
|
</Head>
|
||||||
|
<TurniereNavigation/>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<Login hint="Sie müssen angemeldet sein, um ein Turnier zu bearbeiten."/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Footer/>
|
||||||
|
</div>
|
||||||
|
</Option>
|
||||||
|
<Option condition={true}>
|
||||||
|
<ErrorPageComponent statusCode={ 404 }/>
|
||||||
|
</Option>
|
||||||
|
</UserRestrictor>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapStateToTournamentInfo(state) {
|
function mapStateToTournamentInfo(state) {
|
||||||
const { name } = state.tournamentinfo;
|
const { tournamentname, ownerUsername } = state.tournamentinfo;
|
||||||
return { name };
|
const { isSignedIn, username } = state.userinfo;
|
||||||
|
return { tournamentname, ownerUsername, isSignedIn, username };
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue