feat(tournament): add number of tables feature and update related logic
- Introduced a new field `numberOfTables` in the Tournament model to track the number of tables for tournaments. - Updated the tournament update logic to include `numberOfTables` when modifying tournament details. - Added a new endpoint to set the table number for matches, enhancing match management. - Updated frontend components to support the new `numberOfTables` feature, including input fields and table distribution logic. - Enhanced internationalization with new translation keys for table-related features.
This commit is contained in:
@@ -2138,8 +2138,8 @@ Ve // 2. Neues Turnier anlegen
|
||||
return JSON.parse(JSON.stringify(t));
|
||||
}
|
||||
|
||||
// Update Turnier (Name, Datum und Gewinnsätze)
|
||||
async updateTournament(userToken, clubId, tournamentId, name, date, winningSets) {
|
||||
// Update Turnier (Name, Datum, Gewinnsätze und Tischanzahl)
|
||||
async updateTournament(userToken, clubId, tournamentId, name, date, winningSets, numberOfTables) {
|
||||
await checkAccess(userToken, clubId);
|
||||
const tournament = await Tournament.findOne({ where: { id: tournamentId, clubId } });
|
||||
if (!tournament) {
|
||||
@@ -2162,6 +2162,12 @@ Ve // 2. Neues Turnier anlegen
|
||||
}
|
||||
tournament.winningSets = winningSets;
|
||||
}
|
||||
if (numberOfTables !== undefined) {
|
||||
if (numberOfTables !== null && numberOfTables < 1) {
|
||||
throw new Error('Anzahl der Tische muss mindestens 1 sein');
|
||||
}
|
||||
tournament.numberOfTables = numberOfTables;
|
||||
}
|
||||
|
||||
await tournament.save();
|
||||
return JSON.parse(JSON.stringify(tournament));
|
||||
@@ -3355,6 +3361,20 @@ Ve // 2. Neues Turnier anlegen
|
||||
await match.save();
|
||||
}
|
||||
|
||||
async setMatchTableNumber(userToken, clubId, tournamentId, matchId, tableNumber) {
|
||||
await checkAccess(userToken, clubId);
|
||||
|
||||
const match = await TournamentMatch.findOne({
|
||||
where: { id: matchId, tournamentId }
|
||||
});
|
||||
if (!match) {
|
||||
throw new Error("Match nicht gefunden");
|
||||
}
|
||||
|
||||
match.tableNumber = tableNumber != null && tableNumber !== '' ? Number(tableNumber) : null;
|
||||
await match.save();
|
||||
}
|
||||
|
||||
async resetKnockout(userToken, clubId, tournamentId, classId = null) {
|
||||
await checkAccess(userToken, clubId);
|
||||
// lösche alle Matches außer Gruppenphase
|
||||
|
||||
Reference in New Issue
Block a user