import { formatDatumNl } from '@shared/kernel/datum'; import { Aanvraag, AanvraagStatus, AanvraagType } from './aanvraag'; /** View-model mapping for an aanvraag: type → labels, status → label, and the fields for a CIBG "aanvragen" row / the case-detail page. Pure, no Angular — the UI renders these, it does not derive them. */ export const TYPE_LABELS: Record = { registratie: $localize`:@@aanvraagBlock.type.registratie:Inschrijving`, herregistratie: $localize`:@@aanvraagBlock.type.herregistratie:Herregistratie`, intake: $localize`:@@aanvraagBlock.type.intake:Herregistratie-intake`, }; /** What the aanvraag is for (shown under the title). */ export function purposeLabel(type: AanvraagType): string { switch (type) { case 'registratie': return $localize`:@@aanvraag.purpose.registratie:Inschrijving in het BIG-register`; case 'herregistratie': return $localize`:@@aanvraag.purpose.herregistratie:Verlenging van uw BIG-registratie`; case 'intake': return $localize`:@@aanvraag.purpose.intake:Intake-vragenlijst voor uw herregistratie`; } } /** The status as a plain label (what state the aanvraag is in). */ export function statusLabel(status: AanvraagStatus): string { switch (status.tag) { case 'Concept': return $localize`:@@aanvraag.status.concept:Concept (nog niet ingediend)`; case 'InBehandeling': return $localize`:@@aanvraag.status.inBehandeling:In behandeling`; case 'Goedgekeurd': return $localize`:@@aanvraag.status.goedgekeurd:Goedgekeurd`; case 'Afgewezen': return $localize`:@@aanvraag.status.afgewezen:Afgewezen`; } } /** The reference number, or '' for a Concept (which has none yet). */ export function referentie(status: AanvraagStatus): string { return status.tag === 'Concept' ? '' : status.referentie; } export interface AanvraagRow { heading: string; /** What the aanvraag is for (the `.subtitle` line). */ subtitle: string; /** The status: label + reference + submit date (+ any note) — the `.status` line. */ status: string; } /** Fields for a submitted aanvraag's row in the dashboard "aanvragen" list (Concept has no row — it renders as a resumable melding, see aanvraag-block). */ export function submittedRow(a: Aanvraag): AanvraagRow { const s = a.status; const parts = [statusLabel(s)]; const ref = referentie(s); if (ref) parts.push($localize`:@@aanvraag.row.ref:Referentie ${ref}:ref:`); if (a.submittedAt) parts.push( $localize`:@@aanvraag.row.ingediend:ingediend op ${formatDatumNl(a.submittedAt)}:datum:`, ); if (s.tag === 'InBehandeling' && s.manual) parts.push( $localize`:@@aanvraagBlock.manual:Uw aanvraag wordt handmatig beoordeeld in de backoffice.`, ); if (s.tag === 'Afgewezen') parts.push(s.reden); return { heading: TYPE_LABELS[a.type], subtitle: purposeLabel(a.type), status: parts.join(' · '), }; } /** Key/value rows for the case-detail page (CIBG Datablock). */ export function detailRows(a: Aanvraag): { key: string; value: string }[] { const rows = [ { key: $localize`:@@aanvraag.detail.soort:Soort aanvraag`, value: TYPE_LABELS[a.type] }, { key: $localize`:@@aanvraag.detail.waarvoor:Waarvoor`, value: purposeLabel(a.type) }, { key: $localize`:@@aanvraag.detail.status:Status`, value: statusLabel(a.status) }, { key: $localize`:@@aanvraag.detail.referentie:Referentie`, value: referentie(a.status) || '—', }, { key: $localize`:@@aanvraag.detail.ingediend:Ingediend op`, value: a.submittedAt ? formatDatumNl(a.submittedAt) : '—', }, ]; if (a.status.tag === 'Afgewezen') { rows.push({ key: $localize`:@@aanvraag.detail.reden:Reden van afwijzing`, value: a.status.reden, }); } return rows; }