Add error message and prevent submit on tournament creation if not all groups are 100% full

This commit is contained in:
Felix Hamme 2019-06-17 22:42:51 +02:00
parent 0c1f896360
commit d421cb2974
1 changed files with 6 additions and 1 deletions

View File

@ -120,6 +120,7 @@ class CreateTournamentForm extends React.Component {
decrementText="-1" decrementCallback={this.decreaseGroupSize}/> decrementText="-1" decrementCallback={this.decreaseGroupSize}/>
</Col> </Col>
</Row> </Row>
<WarningPopup text='Es gibt noch unvollständige Gruppen.' shown={this.areGroupsIncomplete()}/>
</FormGroup> </FormGroup>
<FormGroup> <FormGroup>
<Label for="teams-group-to-playoff">Wie viele Teams sollen nach der Gruppenphase <Label for="teams-group-to-playoff">Wie viele Teams sollen nach der Gruppenphase
@ -155,6 +156,10 @@ class CreateTournamentForm extends React.Component {
</div>); </div>);
} }
areGroupsIncomplete() {
return this.state.groups.filter(group => group.length !== this.state.groupSize).length !== 0;
}
teamListUpdate(list) { teamListUpdate(list) {
this.setState({teams: list}); this.setState({teams: list});
} }
@ -222,7 +227,7 @@ class CreateTournamentForm extends React.Component {
} }
valuesAreCredible() { valuesAreCredible() {
return this.state.teams.length >= this.state.groupAdvance; return this.state.teams.length >= this.state.groupAdvance && !this.areGroupsIncomplete();
} }
generateTournamentCreationObject() { generateTournamentCreationObject() {