fix(tournament): update birth year eligibility checks in TournamentTab

- Adjusted the logic for member eligibility based on birth year to ensure that members without a valid birth date are not allowed in age-restricted classes.
- Enhanced comments for clarity regarding age restrictions and eligibility criteria, improving the understanding of the filtering logic.
This commit is contained in:
Torsten Schulz (local)
2026-01-30 23:32:52 +01:00
parent c3366313d6
commit 02c947b0e3

View File

@@ -1667,9 +1667,15 @@ export default {
if (classItem.gender === 'male' && g !== 'male') return false;
if (classItem.gender === 'female' && g !== 'female') return false;
}
// Geburtsjahr-Filter
// Wenn Klasse keine Geburtsjahr-Einschränkung hat, alle erlauben
const hasAgeRestriction = classItem.minBirthYear != null || classItem.maxBirthYear != null;
if (!hasAgeRestriction) return true;
// Geburtsjahr-Filter: Bei Altersklassen MUSS ein gültiges Geburtsjahr vorhanden sein
const bd = member.birthDate;
if (!bd) return true; // Kein Geburtsdatum = erlaubt
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);
@@ -1677,20 +1683,9 @@ export default {
const parts = bd.split('.');
if (parts.length >= 3) birthYear = parseInt(parts[2], 10);
}
if (birthYear == null || !Number.isFinite(birthYear)) return true;
// Debug: Zeige Filterung für erste paar Mitglieder
if (Math.random() < 0.1) {
console.log('[memberEligibleForClass]', {
member: `${member.firstName} ${member.lastName}`,
birthYear,
classItem: classItem.name,
minBirthYear: classItem.minBirthYear,
maxBirthYear: classItem.maxBirthYear,
tooOld: classItem.minBirthYear != null && birthYear < classItem.minBirthYear,
tooYoung: classItem.maxBirthYear != null && birthYear > classItem.maxBirthYear
});
}
// 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;