Make sanity check before sending create request to backend
This commit is contained in:
parent
5b64dc6c0e
commit
932cefff7b
|
|
@ -78,6 +78,7 @@ class CreateTournamentForm extends React.Component {
|
||||||
this.increaseGroupSize = this.increaseGroupSize.bind(this);
|
this.increaseGroupSize = this.increaseGroupSize.bind(this);
|
||||||
this.decreaseGroupSize = this.decreaseGroupSize.bind(this);
|
this.decreaseGroupSize = this.decreaseGroupSize.bind(this);
|
||||||
this.generateTournamentCreationObject = this.generateTournamentCreationObject.bind(this);
|
this.generateTournamentCreationObject = this.generateTournamentCreationObject.bind(this);
|
||||||
|
this.valuesAreCredible = this.valuesAreCredible.bind(this);
|
||||||
|
|
||||||
this.create = this.create.bind(this);
|
this.create = this.create.bind(this);
|
||||||
}
|
}
|
||||||
|
|
@ -197,12 +198,18 @@ class CreateTournamentForm extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
create() {
|
create() {
|
||||||
|
if (this.valuesAreCredible()) {
|
||||||
createTournament(this.generateTournamentCreationObject(), () => {
|
createTournament(this.generateTournamentCreationObject(), () => {
|
||||||
notify.show('Das Turnier wurde erfolgreich erstellt.', 'success', 5000);
|
notify.show('Das Turnier wurde erfolgreich erstellt.', 'success', 5000);
|
||||||
}, () => {
|
}, () => {
|
||||||
notify.show('Das Turnier konnte nicht erstellt werden.', 'warning', 5000);
|
notify.show('Das Turnier konnte nicht erstellt werden.', 'warning', 5000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
valuesAreCredible() {
|
||||||
|
return this.state.groups.length >= this.state.groupAdvance;
|
||||||
|
}
|
||||||
|
|
||||||
generateTournamentCreationObject() {
|
generateTournamentCreationObject() {
|
||||||
const tournament = {
|
const tournament = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue