Fix a bug, which causes the tournament site to crash

Whenever a match in the play off stage of a tournament has not had a team determined
yet the tournament site would crash on it since it expected two team objects attached.
This commit is contained in:
JP1998 2019-04-11 16:19:17 +02:00
parent 2e93076d79
commit 980d2eac3d
1 changed files with 21 additions and 6 deletions

View File

@ -361,14 +361,29 @@ function convertGroup(apiGroup) {
}
function convertMatch(apiMatch) {
return {
var result = {
id: apiMatch.id,
state: apiMatch.state,
team1: apiMatch.match_scores[0].team.name,
team2: apiMatch.match_scores[1].team.name,
scoreTeam1: apiMatch.match_scores[0].points,
scoreTeam2: apiMatch.match_scores[1].points
state: apiMatch.state
};
if(apiMatch.match_scores.length == 2) {
result.team1 = apiMatch.match_scores[0].team.name;
result.scoreTeam1 = apiMatch.match_scores[0].points;
result.team2 = apiMatch.match_scores[1].team.name;
result.scoreTeam2 = apiMatch.match_scores[1].points;
} else if(apiMatch.match_scores.length == 1) {
result.team1 = apiMatch.match_scores[0].team.name;
result.scoreTeam1 = apiMatch.match_scores[0].points;
result.team2 = 'TBD';
result.scoreTeam2 = 0;
} else {
result.team1 = 'TBD';
result.scoreTeam1 = 0;
result.team2 = 'TBD';
result.scoreTeam2 = 0;
}
return result;
}
class Main extends React.Component {