import { Component, inject, signal } from '@angular/core'; import { BffApiV1Service, type SubmitAccepted } from 'api-client'; import { AuthService } from 'auth'; import { UtrechtComponentsModule } from 'ui'; /** * The self-service submit page: a signed-in zorgprofessional confirms and submits their BIG * registration. The bsn comes from the DigiD token (not a form field), so this is a confirm-and- * submit flow that posts to the BFF and shows the returned reference (ADR-0010; S-08c). */ @Component({ selector: 'app-registration-page', imports: [UtrechtComponentsModule], templateUrl: './registration-page.html', }) export class RegistrationPage { private readonly auth = inject(AuthService); private readonly bff = inject(BffApiV1Service); protected readonly bsn = this.auth.bsn; protected readonly submitting = signal(false); protected readonly reference = signal(undefined); protected readonly submitted = signal(false); protected readonly failed = signal(false); submit(): void { this.submitting.set(true); this.failed.set(false); this.bff.postSelfServiceRegistrations().subscribe({ next: (accepted: SubmitAccepted) => { this.reference.set(accepted.registrationId); this.submitted.set(true); this.submitting.set(false); }, // Surface the failure instead of swallowing it: re-enable the button so the user can retry. error: () => { this.failed.set(true); this.submitting.set(false); }, }); } }