Mijn aanvragen (D): backend draft-sync + resume-by-link (registratie slice)

Replaces the registratie wizard's sessionStorage draft with a backend-owned
Concept aanvraag (PRD 0001, phase D — the registratie vertical slice).

- createDraftSync (registratie/application): reusable controller (field-initializer
  idiom, like createUploadController). Creates the Concept lazily on first progress,
  stamps `?aanvraag=<id>` into the URL, debounced-syncs the machine snapshot per
  change, and resumes from `?aanvraag` on load. Inert without a Router or when an
  explicit seed is present (Storybook/tests) — no network there.
- hasProgress (machine, pure + spec): "worth persisting?" — excludes the automatic
  BRP address prefill so a bare page visit creates nothing. Accepted regression:
  a step-0-only address edit isn't persisted until the user advances/chooses.
- Wizard: dropped STORAGE_KEY/restore + the sessionStorage effect; restart() detaches
  the Concept and drops the link.

Deferred (noted): ApplicationsStore -> phase F (dashboard is its only consumer);
intake-v3 + herregistratie persistence -> phase E (copy this pattern).
Gates green: vitest 125, lint, build; backend unchanged (dotnet 56).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-01 12:23:30 +02:00
parent 6f250cd987
commit 6db7f1e673
4 changed files with 166 additions and 24 deletions

View File

@@ -91,6 +91,22 @@ export function currentStep(s: Extract<RegistratieState, { tag: 'Invullen' }>):
return STEPS[Math.min(s.cursor, STEPS.length - 1)];
}
/** Has the user meaningfully started, so it's worth persisting as a Concept? Excludes
the automatic BRP address prefill on step 0 — a bare page visit creates nothing.
ponytail: an address typed at step 0 without any of these signals is not yet
persisted (created once they advance/choose); accepted regression vs. sessionStorage. */
export function hasProgress(s: Extract<RegistratieState, { tag: 'Invullen' }>): boolean {
const d = s.draft;
return (
s.cursor > 0 ||
!!d.correspondentie ||
!!d.email ||
!!d.diplomaId ||
!!d.beroep ||
deliveryRefs(s.upload).some((r) => r.channel === 'digital' && !!r.documentId)
);
}
/** Validate every question currently visible in ONE step. Errors keyed per field. */
function validateStep(step: StepId, d: Draft, upload: UploadState): Result<Errors, void> {
const errors: Errors = {};