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.
This commit is contained in:
Torsten Schulz (local)
2026-02-05 23:16:15 +01:00
parent af6048b289
commit 526eca8b97

View File

@@ -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) {