Refactoring the createTeamArray-method

This commit is contained in:
JP1998 2019-04-23 23:52:22 +02:00
parent 6af5f9dc72
commit 2217212a4a
1 changed files with 34 additions and 17 deletions

View File

@ -218,7 +218,7 @@ class CreateTournamentForm extends React.Component {
'description': this.state.description, 'description': this.state.description,
'public': this.state.public, 'public': this.state.public,
'group_stage': this.state.groupPhaseEnabled, 'group_stage': this.state.groupPhaseEnabled,
'teams': this.createTeamArray(this.state.groupPhaseEnabled, this.state.groups, this.state.teams) 'teams': createTeamArray(this.state.groupPhaseEnabled, this.state.groups, this.state.teams)
}, () => { }, () => {
notify.show('Das Turnier wurde erfolgreich erstellt.', 'success', 5000); notify.show('Das Turnier wurde erfolgreich erstellt.', 'success', 5000);
}, () => { }, () => {
@ -226,7 +226,25 @@ class CreateTournamentForm extends React.Component {
}); });
} }
createTeamArray(/* boolean */ groupphase, /* String[][] */ groups, /* String[] */ teams) { }
/**
* This method creates an array of team objects that conform to the currently
* api specs available at https://apidoc.turnie.re/
*
* @param {boolean} groupphase Whether a group phase is to be created
* @param {string[][]} groups The teams split into the groups that are
* to be used in the group phase of the tournament. Please note that
* according to the api every team can only occur once (not enforced
* by this method) and that every team from {@param teams} will have
* to be in one of the groups (also not enforced by this method, but
* might lead to inconsistencies)
* @param {string[]} teams An array containing all names of the teams
* that are to be created for the tournament
* @return {Object[]} an array of teams that can be directly sent to the
* backend
*/
function createTeamArray(groupphase, groups, teams) {
let result = []; let result = [];
if(groupphase) { if(groupphase) {
@ -245,5 +263,4 @@ class CreateTournamentForm extends React.Component {
} }
return result; return result;
}
} }