From 526eca8b97950452747b8a738078982e4d91277d Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Thu, 5 Feb 2026 23:16:15 +0100 Subject: [PATCH] feat(schedule): normalize player lists for match updates - Introduced a `normalizePlayersList` function to handle player data from match updates, ensuring valid and consistent player arrays for `playersReady`, `playersPlanned`, and `playersPlayed`. - Updated the logic in ScheduleView to utilize normalized player lists when setting member statuses, improving data integrity and error handling. --- frontend/src/views/ScheduleView.vue | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/frontend/src/views/ScheduleView.vue b/frontend/src/views/ScheduleView.vue index 89b017a9..ac923fdd 100644 --- a/frontend/src/views/ScheduleView.vue +++ b/frontend/src/views/ScheduleView.vue @@ -436,6 +436,22 @@ export default { this.playerSelectionDialog.loading = true; try { + const normalizePlayersList = (value) => { + if (Array.isArray(value)) return value; + if (typeof value === 'string') { + try { + const parsed = JSON.parse(value); + return Array.isArray(parsed) ? parsed : []; + } catch (e) { + return []; + } + } + return []; + }; + const readyIds = normalizePlayersList(match.playersReady); + const plannedIds = normalizePlayersList(match.playersPlanned); + const playedIds = normalizePlayersList(match.playersPlayed); + // Fetch members for the current club const response = await apiClient.get(`/clubmembers/get/${this.currentClub}/true`); @@ -447,9 +463,9 @@ export default { this.playerSelectionDialog.members = activeMembers.map(m => ({ ...m, - isReady: match.playersReady?.includes(m.id) || false, - isPlanned: match.playersPlanned?.includes(m.id) || false, - hasPlayed: match.playersPlayed?.includes(m.id) || false + isReady: readyIds.includes(m.id) || false, + isPlanned: plannedIds.includes(m.id) || false, + hasPlayed: playedIds.includes(m.id) || false })); } catch (error) {