import { Component, inject, signal } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { BffApiV1Service, type OpenbaarEntry } from 'api-client'; import { UtrechtComponentsModule } from 'ui'; /** * The openbaar (public) BIG-register: an anonymous search over the read projection's public-safe * view (id + status only — bsn/naam never leave the BFF; ADR-0010). Loads the full register on open * and filters by the search term via the BFF's `/openbaar/register?q=` endpoint (S-09). */ @Component({ selector: 'app-register-page', imports: [FormsModule, UtrechtComponentsModule], templateUrl: './register-page.html', }) export class RegisterPage { private readonly bff = inject(BffApiV1Service); protected readonly query = signal(''); protected readonly entries = signal([]); protected readonly loading = signal(false); protected readonly searched = signal(false); constructor() { // Show the full register on open; the search box narrows it. this.search(); } search(): void { const q = this.query().trim(); this.loading.set(true); this.bff.getOpenbaarRegister(q ? { q } : {}).subscribe({ next: (rows: OpenbaarEntry[]) => { this.entries.set(rows); this.loading.set(false); this.searched.set(true); }, error: () => { this.entries.set([]); this.loading.set(false); this.searched.set(true); }, }); } }