b29a268b1d
- Move completed plan files to .plans/done/ - Move 18 open plan files to .plans/open/ - Update .gitignore to exclude .verified_plans temp file - Verified all 18 open plans still describe unimplemented issues
1.7 KiB
1.7 KiB
Issue #205: Date Calculations Duplicated in Frontend
Problem
The MemberList.vue component contains duplicate date calculation logic for alter (age) and mitgliedsdauer (membership duration) that also exists in the backend MemberService:
Backend (lib/Service/MemberService.php):
private function calculateMitgliedsdauer(Member $member): string {
$eintritt = new DateTime($member->getEintritt());
$end = $member->getAustritt()
? new DateTime($member->getAustritt())
: new DateTime();
$diff = $eintritt->diff($end);
// ...
}
Frontend (src/views/MemberList.vue):
function calculateAge(geburtsdatum) {
const birth = new Date(geburtsdatum)
const today = new Date()
let age = today.getFullYear() - birth.getFullYear()
// ...
}
function calculateMitgliedsdauer(eintritt) {
const start = new Date(eintritt)
const today = new Date()
// ...
}
Impact
- Inconsistent calculations if date logic changes
- Maintenance burden (two places to update)
- Potential for bugs if frontend and backend diverge
Solution
- Option A (Recommended): Calculate
alterandmitgliedsdauerin the backend and include them in the API response - Option B: Extract to a shared utility in a format both can use (e.g., precompute in migration, or use a build-time code generator)
Tasks
- Add
alterandmitgliedsdauertoMember::jsonSerialize() - Update
MemberService::buildMemberResponse()to compute these values - Remove duplicate calculations from
MemberList.vue - Verify frontend displays match backend calculations
- Update any other views using these calculations
Labels
- refactoring
- frontend
- backend
- priority:medium