Refactor the handleGroupSizeInput method

This commit is contained in:
JP1998 2019-05-28 22:55:19 +02:00
parent 3bb902b033
commit 2defc3df22
1 changed files with 11 additions and 8 deletions

View File

@ -163,7 +163,11 @@ class CreateTournamentForm extends React.Component {
handleGroupSizeInput(input) { handleGroupSizeInput(input) {
const newSize = input.target.value; const newSize = input.target.value;
if (newSize !== undefined && newSize > 2) {
if (newSize === undefined || newSize < 2) {
return;
}
if (newSize <= this.state.groupAdvance) { if (newSize <= this.state.groupAdvance) {
this.setState({ this.setState({
groupSize: newSize, groupAdvance: newSize - 1 groupSize: newSize, groupAdvance: newSize - 1
@ -172,7 +176,6 @@ class CreateTournamentForm extends React.Component {
this.setState({groupSize: newSize}); this.setState({groupSize: newSize});
} }
} }
}
handleGroupAdvanceInput(input) { handleGroupAdvanceInput(input) {
this.setState({groupAdvance: input.target.value}); this.setState({groupAdvance: input.target.value});