fix(tournament): refine birth date handling and eligibility checks in TournamentTab
- Updated birth date parsing to support both camelCase and snake_case formats, ensuring accurate eligibility checks for age-restricted classes. - Enhanced minimum and maximum birth year comparisons to handle edge cases, improving the robustness of member eligibility filtering.
This commit is contained in:
@@ -1679,22 +1679,28 @@ export default {
|
||||
if (!hasAgeRestriction) return true;
|
||||
|
||||
// Geburtsjahr-Filter: Bei Altersklassen MUSS ein gültiges Geburtsjahr vorhanden sein
|
||||
const bd = member.birthDate;
|
||||
const bd = member.birthDate ?? member.birth_date;
|
||||
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);
|
||||
} else if (typeof bd === 'string' && bd.includes('.')) {
|
||||
const parts = bd.split('.');
|
||||
if (parts.length >= 3) birthYear = parseInt(parts[2], 10);
|
||||
if (bd instanceof Date && !isNaN(bd.getTime())) {
|
||||
birthYear = bd.getFullYear();
|
||||
} else if (typeof bd === 'string') {
|
||||
if (bd.includes('-')) {
|
||||
birthYear = parseInt(bd.split('-')[0], 10);
|
||||
} else if (bd.includes('.')) {
|
||||
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 (minBirthYear != null && birthYear < minBirthYear) return false;
|
||||
if (maxBirthYear != null && birthYear > maxBirthYear) return false;
|
||||
const minY = Number(minBirthYear);
|
||||
const maxY = maxBirthYear != null ? Number(maxBirthYear) : new Date().getFullYear();
|
||||
if (!isNaN(minY) && birthYear < minY) return false;
|
||||
if (!isNaN(maxY) && birthYear > maxY) return false;
|
||||
return true;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user