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.
This commit is contained in:
Torsten Schulz (local)
2026-01-30 23:48:51 +01:00
parent c6f8b4dd74
commit 380709c29c

View File

@@ -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;
},