import { Registration } from './registration'; import { herregistratieDeadline, isHerregistratieEligible } from './registration.policy'; /** * What the dashboard's "Wat moet ik regelen" list needs. Pure presentation data * derived from the registration — no Angular. Mirrors the shared TaskItem shape. */ export interface PortalTask { title: string; description: string; to: string; actionLabel: string; } function formatNL(d: Date): string { return d.toLocaleDateString('nl-NL', { day: 'numeric', month: 'long', year: 'numeric' }); } /** * Derive the open tasks for a professional from their registration (pure; * `today` is injected so it's testable). Herregistratie within its window is the * primary action; a suspended/struck-off registration surfaces as a notice-task. * Reuses the same rules the detail/summary use (registration.policy). */ export function tasksFromProfile(reg: Registration, today: Date): PortalTask[] { const tasks: PortalTask[] = []; if (isHerregistratieEligible(reg, today)) { const deadline = herregistratieDeadline(reg); tasks.push({ title: 'Vraag uw herregistratie aan', description: deadline ? `Verleng uw registratie vóór ${formatNL(deadline)}.` : 'U kunt nu uw herregistratie aanvragen.', to: '/herregistratie', actionLabel: 'Herregistratie aanvragen', }); } if (reg.status.tag === 'Geschorst') { tasks.push({ title: 'Uw registratie is geschorst', description: reg.status.reden, to: '/registratie', actionLabel: 'Bekijk uw gegevens', }); } if (reg.status.tag === 'Doorgehaald') { tasks.push({ title: 'Uw registratie is doorgehaald', description: reg.status.reden, to: '/registratie', actionLabel: 'Bekijk uw gegevens', }); } return tasks; }