From 380709c29ca36a53b72db9f4483cfcd972e08e34 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Fri, 30 Jan 2026 23:48:51 +0100 Subject: [PATCH] fix(tournament): improve birth year eligibility checks in TournamentTab - Updated the logic for determining minimum and maximum birth years to support both camelCase and snake_case formats from the API. - Enhanced member eligibility checks to ensure accurate filtering based on birth year restrictions, improving clarity and functionality in the tournament participant selection process. --- frontend/src/views/TournamentTab.vue | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/frontend/src/views/TournamentTab.vue b/frontend/src/views/TournamentTab.vue index 89a5a77..350d429 100644 --- a/frontend/src/views/TournamentTab.vue +++ b/frontend/src/views/TournamentTab.vue @@ -540,8 +540,10 @@ export default { return this.clubMembers; } const classItem = this.tournamentClasses.find(c => String(c.id) === String(this.selectedViewClass)); + const minYear = classItem?.minBirthYear ?? classItem?.min_birth_year; + const maxYear = classItem?.maxBirthYear ?? classItem?.max_birth_year; // Klasse nicht gefunden oder keine Filter gesetzt: alle Mitglieder - if (!classItem || (classItem.minBirthYear == null && classItem.maxBirthYear == null && !classItem.gender)) { + if (!classItem || (minYear == null && maxYear == null && !classItem.gender)) { return this.clubMembers; } // Filtere nach Geschlecht und Geburtsjahr (min/max) @@ -1661,21 +1663,25 @@ export default { }, memberEligibleForClass(member, classItem) { + // Unterstütze camelCase und snake_case (API könnte beides liefern) + const minBirthYear = classItem.minBirthYear ?? classItem.min_birth_year; + const maxBirthYear = classItem.maxBirthYear ?? classItem.max_birth_year; + // Geschlechtsfilter if (classItem.gender && classItem.gender !== 'mixed') { const g = (member.gender || 'unknown').toLowerCase(); if (classItem.gender === 'male' && g !== 'male') return false; if (classItem.gender === 'female' && g !== 'female') return false; } - + // Wenn Klasse keine Geburtsjahr-Einschränkung hat, alle erlauben - const hasAgeRestriction = classItem.minBirthYear != null || classItem.maxBirthYear != null; + const hasAgeRestriction = minBirthYear != null || maxBirthYear != null; if (!hasAgeRestriction) return true; - + // Geburtsjahr-Filter: Bei Altersklassen MUSS ein gültiges Geburtsjahr vorhanden sein const bd = member.birthDate; if (!bd) return false; // Kein Geburtsdatum = NICHT erlaubt bei Altersklassen - + let birthYear = null; if (typeof bd === 'string' && bd.includes('-')) { birthYear = parseInt(bd.split('-')[0], 10); @@ -1683,12 +1689,12 @@ export default { const parts = bd.split('.'); if (parts.length >= 3) birthYear = parseInt(parts[2], 10); } - + // Kein gültiges Geburtsjahr parsbar = nicht erlaubt bei Altersklassen if (birthYear == null || !Number.isFinite(birthYear)) return false; - - if (classItem.minBirthYear != null && birthYear < classItem.minBirthYear) return false; - if (classItem.maxBirthYear != null && birthYear > classItem.maxBirthYear) return false; + + if (minBirthYear != null && birthYear < minBirthYear) return false; + if (maxBirthYear != null && birthYear > maxBirthYear) return false; return true; },