Add registratie wizard, BFF dashboard-view, contracts/value-objects, and architecture docs
Checkpoint of in-progress work: the registration wizard (address prefill, DUO diploma lookup, policy questions), decision-DTO contracts, parse-don't- validate value objects, infrastructure adapters, plus CLAUDE.md and the architecture/ADR docs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { Injectable, computed, inject, signal } from '@angular/core';
|
||||
import { RemoteData, fromResource, map2 } from '@shared/application/remote-data';
|
||||
import { RemoteData, fromResource, map } from '@shared/application/remote-data';
|
||||
import { Aantekening } from '../domain/registration';
|
||||
import { BigProfile } from '../domain/big-profile';
|
||||
import { HerregistratieDecisions, DashboardView } from '../contracts/dashboard-view.dto';
|
||||
import { BigRegisterAdapter } from '../infrastructure/big-register.adapter';
|
||||
import { BrpAdapter } from '../infrastructure/brp.adapter';
|
||||
import { DashboardViewAdapter, parseDashboardView } from '../infrastructure/dashboard-view.adapter';
|
||||
|
||||
type Err = Error | undefined;
|
||||
|
||||
@@ -13,29 +14,32 @@ type Err = Error | undefined;
|
||||
* (created here, in the required injection context) and exposes them as
|
||||
* RemoteData signals.
|
||||
*
|
||||
* The headline trick: `profile` combines TWO independent services — the
|
||||
* BIG-register and the BRP — into ONE RemoteData via map2. A page renders a
|
||||
* single state (loading / error / loaded), never juggling three.
|
||||
* The dashboard data now comes from ONE screen-shaped ("BFF-lite") call that
|
||||
* returns registration + person + server-computed `decisions`. One request → one
|
||||
* consistent snapshot, instead of stitching three independently loading/erroring
|
||||
* resources together client-side. See docs/architecture/0001-bff-lite-decision-dtos.md.
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class BigProfileStore {
|
||||
private big = inject(BigRegisterAdapter);
|
||||
private brp = inject(BrpAdapter);
|
||||
private viewAdapter = inject(DashboardViewAdapter);
|
||||
|
||||
private registrationRes = this.big.registrationResource();
|
||||
private viewRes = this.viewAdapter.dashboardViewResource();
|
||||
private aantekeningenRes = this.big.aantekeningenResource();
|
||||
private personRes = this.brp.personResource();
|
||||
|
||||
/** BIG-register + BRP folded into one state. */
|
||||
readonly profile = computed<RemoteData<Err, BigProfile>>(() =>
|
||||
map2(
|
||||
fromResource(this.registrationRes),
|
||||
fromResource(this.personRes),
|
||||
// httpResource types value as T | undefined; in the Success branch it is
|
||||
// always present, so narrowing here is safe.
|
||||
(registration, person) => ({ registration: registration!, person: person! }),
|
||||
),
|
||||
);
|
||||
/** The aggregated view, validated at the trust boundary (DTO → domain). */
|
||||
private view = computed<RemoteData<Err, DashboardView>>(() => {
|
||||
const rd = fromResource(this.viewRes);
|
||||
if (rd.tag !== 'Success') return rd;
|
||||
const parsed = parseDashboardView(rd.value);
|
||||
return parsed.ok ? { tag: 'Success', value: parsed.value } : { tag: 'Failure', error: new Error(parsed.error) };
|
||||
});
|
||||
|
||||
/** Registration + person, from the single aggregated call. */
|
||||
readonly profile = computed<RemoteData<Err, BigProfile>>(() => map(this.view(), (v) => v.profile));
|
||||
|
||||
/** Server-computed decisions (e.g. herregistratie eligibility) — rendered, not recomputed. */
|
||||
readonly decisions = computed<RemoteData<Err, HerregistratieDecisions>>(() => map(this.view(), (v) => v.decisions));
|
||||
|
||||
/** Specialisms/notes stay a separate stream (they have their own empty state). */
|
||||
readonly aantekeningen = computed<RemoteData<Err, Aantekening[]>>(() =>
|
||||
@@ -52,7 +56,7 @@ export class BigProfileStore {
|
||||
}
|
||||
confirmHerregistratie() {
|
||||
this.pending.set(false);
|
||||
this.registrationRes.reload(); // invalidate: re-fetch the now-updated registration
|
||||
this.viewRes.reload(); // invalidate: re-fetch the now-updated view (registration + decisions)
|
||||
}
|
||||
rollbackHerregistratie() {
|
||||
this.pending.set(false); // submission failed — undo the optimistic flag
|
||||
|
||||
19
src/app/registratie/application/submit-registratie.ts
Normal file
19
src/app/registratie/application/submit-registratie.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Result, ok, err } from '@shared/kernel/fp';
|
||||
import { ValidRegistratie } from '@registratie/domain/registratie-wizard.machine';
|
||||
|
||||
/**
|
||||
* Command: send the completed registration to the backend, which invokes the
|
||||
* domain command to create/finalize the registration aggregate. Returns a Result
|
||||
* so the caller branches on success/failure without try/catch; on success it
|
||||
* yields the confirmation reference (PRD §9). ponytail: faked with a timer; swap
|
||||
* for a real POST when there's an API. The "manually entered diploma" rule lets
|
||||
* the demo show the failure path.
|
||||
*/
|
||||
export async function submitRegistratie(data: ValidRegistratie): Promise<Result<string, string>> {
|
||||
await new Promise((r) => setTimeout(r, 800));
|
||||
if (data.diplomaHerkomst === 'handmatig') {
|
||||
return err('Een handmatig ingevoerd diploma kan niet automatisch worden geverifieerd. Uw aanvraag is doorgestuurd voor handmatige beoordeling.');
|
||||
}
|
||||
const referentie = 'BIG-2026-' + Math.floor(100000 + Math.random() * 900000);
|
||||
return ok(referentie);
|
||||
}
|
||||
Reference in New Issue
Block a user