refactor: add successOr, sweep remaining inline unwraps (RD-17)
Eight sites hand-rolled `rd.tag === 'Success' ? rd.value : fallback`. Six take the new `successOr(rd, fallback)`, one takes the existing `successOf`, and one (`big-profile.store.ts`) uses the existing `map`, since it returns a RemoteData rather than an unwrapped value. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Component, computed, inject } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { successOf } from '@shared/application/remote-data';
|
||||
import { PageShellComponent } from '@shared/layout/page-shell/page-shell.component';
|
||||
import { AlertComponent } from '@shared/ui/alert/alert.component';
|
||||
import { ButtonComponent } from '@shared/ui/button/button.component';
|
||||
@@ -73,10 +74,7 @@ export class BeoordelingPage {
|
||||
protected retryText = $localize`:@@beoordeling.retry:Opnieuw proberen`;
|
||||
|
||||
protected rows = detailRows;
|
||||
protected readonly view = computed(() => {
|
||||
const rd = this.store.view();
|
||||
return rd.tag === 'Success' ? rd.value : undefined;
|
||||
});
|
||||
protected readonly view = computed(() => successOf(this.store.view()));
|
||||
|
||||
constructor() {
|
||||
void this.store.load(this.id);
|
||||
|
||||
@@ -5,6 +5,7 @@ import { ButtonComponent } from '@shared/ui/button/button.component';
|
||||
import { SkeletonComponent } from '@shared/ui/skeleton/skeleton.component';
|
||||
import { ASYNC } from '@shared/ui/async/async.component';
|
||||
import { AccessStore } from '@shared/application/access.store';
|
||||
import { successOr } from '@shared/application/remote-data';
|
||||
import { WerkvoorraadStore } from '@behandeling/application/werkvoorraad.store';
|
||||
import { WerkvoorraadListComponent } from '@behandeling/ui/werkvoorraad-list/werkvoorraad-list.component';
|
||||
|
||||
@@ -56,10 +57,7 @@ export class WerkvoorraadPage {
|
||||
protected access = inject(AccessStore);
|
||||
|
||||
protected canBeoordelen = computed(() => this.access.can('aanvraag:beoordelen'));
|
||||
protected items = computed(() => {
|
||||
const rd = this.store.items();
|
||||
return rd.tag === 'Success' ? rd.value : [];
|
||||
});
|
||||
protected items = computed(() => successOr(this.store.items(), []));
|
||||
|
||||
protected heading = $localize`:@@werkvoorraad.heading:Werkvoorraad`;
|
||||
protected intro = $localize`:@@werkvoorraad.intro:Aanvragen die op beoordeling wachten.`;
|
||||
|
||||
Reference in New Issue
Block a user