Fügt die Funktion zum Laden von Turnieren beim Start hinzu und optimiert die Turniererstellung, um die Turnierliste nach der Erstellung eines neuen Turniers automatisch zu aktualisieren. Verbessert die Anzeige von Turnierdaten, indem der Turniername priorisiert wird, und behandelt Fehler beim Laden und Erstellen von Turnieren.
This commit is contained in:
@@ -6,11 +6,11 @@
|
||||
<select v-model="selectedDate">
|
||||
<option value="new">Neues Turnier</option>
|
||||
<option v-for="date in dates" :key="date.id" :value="date.id">
|
||||
{{ new Date(date.date).toLocaleDateString('de-DE', {
|
||||
{{ date.tournamentName || (date.date ? new Date(date.date).toLocaleDateString('de-DE', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit'
|
||||
}) }}
|
||||
}) : 'Unbekanntes Datum') }}
|
||||
</option>
|
||||
</select>
|
||||
<div v-if="selectedDate === 'new'" class="new-tournament">
|
||||
@@ -476,6 +476,9 @@ export default {
|
||||
this.clubMembers = m.data;
|
||||
},
|
||||
mounted() {
|
||||
// Lade Turniere beim Start
|
||||
this.loadTournaments();
|
||||
|
||||
// Event-Listener für das Entfernen des Highlights
|
||||
document.addEventListener('click', (e) => {
|
||||
// Entferne Highlight nur wenn nicht auf eine Matrix-Zelle geklickt wird
|
||||
@@ -575,15 +578,41 @@ export default {
|
||||
return p.member.firstName + ' ' + p.member.lastName;
|
||||
},
|
||||
|
||||
async loadTournaments() {
|
||||
try {
|
||||
const d = await apiClient.get(`/tournament/${this.currentClub}`);
|
||||
this.dates = d.data;
|
||||
console.log('Loaded tournaments:', this.dates);
|
||||
} catch (error) {
|
||||
console.error('Fehler beim Laden der Turniere:', error);
|
||||
this.dates = [];
|
||||
}
|
||||
},
|
||||
|
||||
async createTournament() {
|
||||
const r = await apiClient.post('/tournament', {
|
||||
clubId: this.currentClub,
|
||||
tournamentName: this.newDate,
|
||||
date: this.newDate
|
||||
});
|
||||
this.dates = r.data;
|
||||
this.selectedDate = this.dates[this.dates.length - 1].id;
|
||||
this.newDate = '';
|
||||
try {
|
||||
const r = await apiClient.post('/tournament', {
|
||||
clubId: this.currentClub,
|
||||
tournamentName: this.newDate,
|
||||
date: this.newDate
|
||||
});
|
||||
|
||||
console.log('Tournament created, response:', r.data);
|
||||
|
||||
// Speichere die ID des neuen Turniers
|
||||
const newTournamentId = r.data.id;
|
||||
|
||||
// Lade die Turniere neu
|
||||
await this.loadTournaments();
|
||||
|
||||
// Setze das neue Turnier als ausgewählt
|
||||
this.selectedDate = newTournamentId;
|
||||
|
||||
this.newDate = '';
|
||||
} catch (error) {
|
||||
console.error('Fehler beim Erstellen des Turniers:', error);
|
||||
alert('Fehler beim Erstellen des Turniers: ' + (error.response?.data?.error || error.message));
|
||||
}
|
||||
},
|
||||
|
||||
async addParticipant() {
|
||||
|
||||
Reference in New Issue
Block a user