First steps for tournament

This commit is contained in:
Torsten Schulz
2025-03-13 16:19:07 +01:00
parent df41720b50
commit 821f9d24f5
5 changed files with 111 additions and 16 deletions

View File

@@ -82,15 +82,16 @@
<th>&nbsp;</th>
<th>Begegnung</th>
<th>Sätze</th>
<th>Ergebnis</th>
</tr>
</thead>
<tbody>
<tr v-for="match in matches" :key="match.id">
<td>{{ match.groupId ? "Gr " + match.groupId : match.round }}</td>
<td>{{ getPlayerName(match.player1) }} - {{ getPlayerName(match.player2) }}</td>
<td><input size="5" type="text" v-model="match.result" @keyup.enter="saveMatchResult(match, match.result)" /></td>
<td></td>
<td v-for="result in match.tournamentResults">{{ result.pointsPlayer1 }}:{{ result.pointsPlayer2 }}</td>
<td><input size="5" type="text" v-model="match.result" @keyup.enter="saveMatchResult(match, match.tournamentResults.length + 1, match.result)" /></td>
<td v-if="match.isFinished">{{ match.result ?? '0:0' }}</td>
<td v-else><button @click="finishMatch(match)">Abschließen</button></td>
</tr>
</tbody>
</table>
@@ -249,19 +250,32 @@ export default {
getPlayerName(player) {
return player.member.firstName + ' ' + player.member.lastName;
},
async saveMatchResult(match, result) {
async saveMatchResult(match, set, result) {
try {
await apiClient.post('/tournament/match/result', {
clubId: this.currentClub,
tournamentId: this.selectedDate,
matchId: match.matchId,
matchId: match.id,
set,
result: result,
});
match.result = result; // Aktualisiere das Match in der UI
this.fetchGroups();
} catch (error) {
console.error('Error saving match result:', error);
}
}
},
async finishMatch(match) {
try {
await apiClient.post('/tournament/match/finish', {
clubId: this.currentClub,
tournamentId: this.selectedDate,
matchId: match.id,
});
this.fetchGroups();
} catch (error) {
console.error('Error finishing match:', error);
}
},
},
};
</script>