import { Component, inject, signal } from '@angular/core'; import { BeheerZaaktype, BffApiV1Service } from 'api-client'; import { UtrechtComponentsModule } from 'ui'; /** * The beheer catalogus viewer (S-15a): a signed-in beheerder sees the published ZTC zaaktypen, * read-only. The list is served by the BFF (`GET /beheer/catalogi/zaaktypen`), which proxies the ACL — * the only code allowed to read the ZGW Catalogi API (§8.1, ADR-0025). Managing default-fill is S-15b. */ @Component({ selector: 'app-catalogus-page', imports: [UtrechtComponentsModule], templateUrl: './catalogus-page.html', }) export class CatalogusPage { private readonly bff = inject(BffApiV1Service); protected readonly items = signal([]); protected readonly loading = signal(false); protected readonly loaded = signal(false); protected readonly failed = signal(false); constructor() { this.load(); } load(): void { this.loading.set(true); this.failed.set(false); this.bff.getBeheerCatalogiZaaktypen().subscribe({ next: (rows: BeheerZaaktype[]) => { this.items.set(rows); this.loading.set(false); this.loaded.set(true); }, // Surface the failure (e.g. 403 for a non-beheerder) instead of swallowing it. error: () => { this.items.set([]); this.loading.set(false); this.loaded.set(true); this.failed.set(true); }, }); } }