Use loading page for tournament edit page

This commit is contained in:
Felix Hamme 2019-06-20 16:10:17 +02:00
parent 8b773d5067
commit 5589e8c97e
1 changed files with 10 additions and 4 deletions

View File

@ -19,6 +19,7 @@ import 'bootstrap/dist/css/bootstrap.min.css';
import '../static/css/everypage.css'; import '../static/css/everypage.css';
import '../static/css/index.css'; import '../static/css/index.css';
import {LoadingPage} from '../js/components/LoadingPage';
class EditTournamentPage extends React.Component { class EditTournamentPage extends React.Component {
static async getInitialProps({query}) { static async getInitialProps({query}) {
@ -29,26 +30,31 @@ class EditTournamentPage extends React.Component {
super(props); super(props);
this.state = { this.state = {
validCode: false validCode: false,
loaded: false
}; };
} }
componentDidMount() { componentDidMount() {
requestTournament(this.props.query.code, () => { requestTournament(this.props.query.code, () => {
this.setState({validCode: true}); this.setState({validCode: true, loaded: true});
if (this._edittournamentcontent != null) { if (this._edittournamentcontent != null) {
this._edittournamentcontent.notifyOfContentUpdate(); this._edittournamentcontent.notifyOfContentUpdate();
} }
}, () => { }, () => {
this.setState({validCode: false}); this.setState({validCode: false, loaded: true});
}); });
} }
render() { render() {
const {validCode} = this.state; const {validCode, loaded} = this.state;
const {tournamentname, ownerUsername, isSignedIn, username} = this.props; const {tournamentname, ownerUsername, isSignedIn, username} = this.props;
if (!loaded) {
return <LoadingPage title='turnie.re' text='Turnier-Einstellungen werden geladen...'/>;
}
return (<UserRestrictor> return (<UserRestrictor>
<Option condition={validCode && isSignedIn && ownerUsername === username}> <Option condition={validCode && isSignedIn && ownerUsername === username}>
<div className='pb-5'> <div className='pb-5'>