import { Component, inject, input, output } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { FormFieldComponent } from '@shared/ui/form-field/form-field.component'; import { TextInputComponent } from '@shared/ui/text-input/text-input.component'; import { RadioGroupComponent } from '@shared/ui/radio-group/radio-group.component'; import { AlertComponent } from '@shared/ui/alert/alert.component'; import { SkeletonComponent } from '@shared/ui/skeleton/skeleton.component'; import { AddressFieldsComponent } from '@registratie/ui/address-fields/address-fields.component'; import { RegistratieLookupStore } from '@registratie/application/registratie-lookup.store'; import { Draft, DraftField, Errors } from '@registratie/domain/registratie-wizard.machine'; const KANALEN = [ { value: 'email', label: $localize`:@@registratie.kanaalEmail:E-mail` }, { value: 'post', label: $localize`:@@registratie.kanaalPost:Post` }, ]; /** Step: the registratie wizard's first screen (adres + correspondentievoorkeur). Injects RegistratieLookupStore directly for the BRP lookup banner — the sanctioned exception (it is `providedIn: 'root'`, so every injection is the same instance): the step owns its own async presentation rather than making the parent a pass-through for it. Values otherwise in via `draft`/`errors`, every change out via `fieldChange`/`kanaalChange`. No internal state; the parent owns the Model and decides what a change means. */ @Component({ selector: 'app-reg-adres-step', imports: [ FormsModule, FormFieldComponent, TextInputComponent, RadioGroupComponent, AlertComponent, SkeletonComponent, AddressFieldsComponent, ], template: ` @if (adresStatus() === 'laden') { } @else { @switch (adresStatus()) { @case ('gevonden') { Vooraf ingevuld op basis van de BRP. Controleer en pas zo nodig aan. } @case ('geen') { We vonden geen adres in de BRP. Vul uw adres hieronder handmatig in. } @case ('fout') { We konden de BRP nu niet bereiken. Vul uw adres hieronder handmatig in. } }
@if (draft().correspondentie === 'email') {
} } `, }) export class AdresStep { private lookup = inject(RegistratieLookupStore); draft = input.required(); errors = input.required(); fieldChange = output<{ key: DraftField; value: string }>(); kanaalChange = output(); protected adresStatus = this.lookup.adresStatus; readonly kanalen = KANALEN; protected err = (k: DraftField | 'correspondentie') => this.errors()[k] ?? ''; }