feat(tournament): update mini championship creation to include location
- Modified addMiniChampionship method to accept location (ort) instead of tournament name. - Updated frontend components to reflect the change, including new input for location and localization updates for German language support. - Enhanced validation to ensure location is provided during mini championship creation.
This commit is contained in:
@@ -75,12 +75,12 @@ export const addTournament = async (req, res) => {
|
||||
}
|
||||
};
|
||||
|
||||
// Minimeisterschaft anlegen (Turnier + 6 Klassen)
|
||||
// Minimeisterschaft anlegen (Turnier + 6 Klassen); Name: "Minimeisterschaften <Jahr> Ortsentscheid <ort>"
|
||||
export const addMiniChampionship = async (req, res) => {
|
||||
const { authcode: token } = req.headers;
|
||||
const { clubId, tournamentName, date, year, winningSets } = req.body;
|
||||
const { clubId, ort, date, year, winningSets } = req.body;
|
||||
try {
|
||||
const tournament = await tournamentService.addMiniChampionship(token, clubId, tournamentName, date, year, winningSets);
|
||||
const tournament = await tournamentService.addMiniChampionship(token, clubId, ort, date, year, winningSets);
|
||||
if (clubId && tournament && tournament.id) {
|
||||
emitTournamentChanged(clubId, tournament.id);
|
||||
}
|
||||
|
||||
@@ -716,10 +716,15 @@ class TournamentService {
|
||||
|
||||
/**
|
||||
* Minimeisterschaft anlegen: Turnier + 6 vorkonfigurierte Klassen (Jungen/Mädchen 12, 10, 8).
|
||||
* Name wird generiert: "Minimeisterschaften <Jahr> Ortsentscheid <ort>".
|
||||
* Jahr Y: 12 = in Y 11 oder 12 Jahre (Geburtsjahr Y-12 oder Y-11), 10 = 9/10 (Y-10, Y-9), 8 = 8 oder jünger (≥ Y-8).
|
||||
*/
|
||||
async addMiniChampionship(userToken, clubId, tournamentName, date, year, winningSets = 3) {
|
||||
async addMiniChampionship(userToken, clubId, ort, date, year, winningSets = 3) {
|
||||
await checkAccess(userToken, clubId);
|
||||
const ortTrimmed = (ort || '').trim();
|
||||
if (!ortTrimmed) {
|
||||
throw new Error('Ort für die Minimeisterschaft fehlt');
|
||||
}
|
||||
const existing = await Tournament.findOne({ where: { clubId, date } });
|
||||
if (existing) {
|
||||
throw new Error('Ein Turnier mit diesem Datum existiert bereits');
|
||||
@@ -728,6 +733,7 @@ class TournamentService {
|
||||
if (!Number.isFinite(Y) || Y < 2000 || Y > 2100) {
|
||||
throw new Error('Ungültiges Jahr für die Minimeisterschaft');
|
||||
}
|
||||
const tournamentName = `Minimeisterschaften ${Y} Ortsentscheid ${ortTrimmed}`;
|
||||
const t = await Tournament.create({
|
||||
name: tournamentName,
|
||||
date,
|
||||
|
||||
@@ -565,6 +565,7 @@
|
||||
"newMiniChampionship": "Neue Minimeisterschaft",
|
||||
"miniChampionshipYear": "Jahr (Altersstufen)",
|
||||
"miniChampionshipYearHint": "12 = in diesem Jahr 11 oder 12 Jahre, 10 = 9 oder 10, 8 = 8 oder jünger",
|
||||
"miniChampionshipLocation": "Ort",
|
||||
"tournamentParticipations": "Turnierteilnahmen",
|
||||
"date": "Datum",
|
||||
"newTournament": "Neues Turnier",
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
<div v-if="selectedDate === 'new'" class="new-tournament">
|
||||
<template v-if="isMiniChampionship">
|
||||
<label>
|
||||
{{ $t('tournaments.name') }}:
|
||||
<input type="text" v-model="newTournamentName" :placeholder="$t('tournaments.tournamentName')" />
|
||||
{{ $t('tournaments.miniChampionshipLocation') }}:
|
||||
<input type="text" v-model="newMiniOrt" :placeholder="$t('tournaments.miniChampionshipLocation')" />
|
||||
</label>
|
||||
<label>
|
||||
{{ $t('tournaments.date') }}:
|
||||
@@ -334,6 +334,7 @@ export default {
|
||||
newTournamentName: '',
|
||||
newWinningSets: 3,
|
||||
newMiniYear: new Date().getFullYear(),
|
||||
newMiniOrt: '',
|
||||
currentTournamentName: '',
|
||||
currentTournamentDate: '',
|
||||
currentWinningSets: 3,
|
||||
@@ -1610,6 +1611,11 @@ export default {
|
||||
},
|
||||
|
||||
async createMiniChampionship() {
|
||||
const ort = (this.newMiniOrt || '').trim();
|
||||
if (!ort) {
|
||||
await this.showInfo(this.$t('messages.error'), this.$t('tournaments.miniChampionshipLocation') + ' eingeben.', '', 'error');
|
||||
return;
|
||||
}
|
||||
if (!this.newDate) {
|
||||
await this.showInfo(this.$t('messages.error'), this.$t('tournaments.pleaseEnterDate'), '', 'error');
|
||||
return;
|
||||
@@ -1622,7 +1628,7 @@ export default {
|
||||
try {
|
||||
const r = await apiClient.post('/tournament/mini', {
|
||||
clubId: this.currentClub,
|
||||
tournamentName: this.newTournamentName || (`Minimeisterschaft ${year}`),
|
||||
ort,
|
||||
date: this.newDate,
|
||||
year,
|
||||
winningSets: this.newWinningSets
|
||||
@@ -1631,7 +1637,7 @@ export default {
|
||||
await this.loadTournaments();
|
||||
this.selectedDate = newTournamentId;
|
||||
this.newDate = '';
|
||||
this.newTournamentName = '';
|
||||
this.newMiniOrt = '';
|
||||
this.newMiniYear = new Date().getFullYear();
|
||||
this.newWinningSets = 3;
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user