Update the Match when the scores are submitted
This commit is contained in:
parent
4e8a690d2a
commit
ba38864a1c
|
|
@ -21,6 +21,7 @@ export class Match extends React.Component {
|
|||
this.onEndMatchSuccess = this.onEndMatchSuccess.bind(this);
|
||||
this.onEndMatchError = this.onEndMatchError.bind(this);
|
||||
this.getMatchFinishedMessage = this.getMatchFinishedMessage.bind(this);
|
||||
this.changeScores = this.changeScores.bind(this);
|
||||
}
|
||||
|
||||
toggleModal() {
|
||||
|
|
@ -64,6 +65,13 @@ export class Match extends React.Component {
|
|||
notify.show('Das Match konnte nicht beendet werden.', 'error', 3000);
|
||||
}
|
||||
|
||||
changeScores(scoreTeam1, scoreTeam2) {
|
||||
const updatedMatch = this.state.match;
|
||||
updatedMatch.team1.score = scoreTeam1;
|
||||
updatedMatch.team2.score = scoreTeam2;
|
||||
this.setState({match: updatedMatch});
|
||||
}
|
||||
|
||||
getMatchFinishedMessage() {
|
||||
const match = this.state.match;
|
||||
if (match.winnerTeamId === null) {
|
||||
|
|
@ -114,7 +122,7 @@ export class Match extends React.Component {
|
|||
</Card>
|
||||
<small className='text-muted'>{smallMessage}</small>
|
||||
<MatchModal title='Match' isOpen={this.state.modal} toggle={this.toggleModal} match={this.state.match}
|
||||
startMatch={this.startMatch} endMatch={this.endMatch}/>
|
||||
startMatch={this.startMatch} endMatch={this.endMatch} changeScores={this.changeScores}/>
|
||||
</div>);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ export class MatchModal extends Component {
|
|||
|
||||
onSubmitScoresSuccess() {
|
||||
this.props.toggle();
|
||||
this.props.changeScores(this.state.scoreTeam1, this.state.scoreTeam2);
|
||||
notify.show('Der Spielstand wurde geändert.', 'success', 2000);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue