From 18a191f6867ae8c30fa95e99bc2389a2d8de9331 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Fri, 30 Jan 2026 22:32:47 +0100 Subject: [PATCH] fix(tournament): improve match identification logic for player IDs - Updated the getMatchLiveResult and handleMatchClick methods to handle potential null values for player IDs, ensuring robust match identification. - Refactored ID retrieval logic to use optional chaining and fallback values, enhancing code readability and preventing errors when player data is incomplete. --- cd | 0 .../tournament/TournamentGroupsTab.vue | 20 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 cd diff --git a/cd b/cd new file mode 100644 index 0000000..e69de29 diff --git a/frontend/src/components/tournament/TournamentGroupsTab.vue b/frontend/src/components/tournament/TournamentGroupsTab.vue index d31809a..395efc3 100644 --- a/frontend/src/components/tournament/TournamentGroupsTab.vue +++ b/frontend/src/components/tournament/TournamentGroupsTab.vue @@ -346,11 +346,14 @@ export default { return classItem ? Boolean(classItem.isDoubles) : false; }, getMatchLiveResult(player1Id, player2Id, groupId) { + const id1 = (m) => m.player1?.id ?? m.player1Id; + const id2 = (m) => m.player2?.id ?? m.player2Id; const match = this.matches.find(m => m.round === 'group' && m.groupId === groupId && - ((m.player1.id === player1Id && m.player2.id === player2Id) || - (m.player1.id === player2Id && m.player2.id === player1Id)) + id1(m) != null && id2(m) != null && + ((id1(m) === player1Id && id2(m) === player2Id) || + (id1(m) === player2Id && id2(m) === player1Id)) ); if (!match) return null; @@ -410,13 +413,13 @@ export default { const playerMatches = this.matches.filter(m => m.round === 'group' && m.groupId === groupId && - (m.player1.id === player.id || m.player2.id === player.id) && + ((m.player1?.id ?? m.player1Id) === player.id || (m.player2?.id ?? m.player2Id) === player.id) && !m.isFinished && m.tournamentResults && m.tournamentResults.length > 0 ); playerMatches.forEach(match => { - const isPlayer1 = match.player1.id === player.id; + const isPlayer1 = (match.player1?.id ?? match.player1Id) === player.id; match.tournamentResults.forEach(result => { if (isPlayer1) { if (result.pointsPlayer1 > result.pointsPlayer2) { @@ -457,12 +460,15 @@ export default { handleMatchClick(player1Id, player2Id, groupId) { // Highlight das Match this.$emit('highlight-match', player1Id, player2Id, groupId); - // Finde das Match und gehe zum Ergebnistab + // Finde das Match und gehe zum Ergebnistab (player1/player2 können null sein, wenn Spieler gelöscht) + const id1 = (m) => m.player1?.id ?? m.player1Id; + const id2 = (m) => m.player2?.id ?? m.player2Id; const match = this.matches.find(m => m.round === 'group' && m.groupId === groupId && - ((m.player1.id === player1Id && m.player2.id === player2Id) || - (m.player1.id === player2Id && m.player2.id === player1Id)) + id1(m) != null && id2(m) != null && + ((id1(m) === player1Id && id2(m) === player2Id) || + (id1(m) === player2Id && id2(m) === player1Id)) ); if (match) { this.$emit('go-to-match', match.id);