refactor: split dashboard.page.ts into per-concern sections
Each dashboard section (Mijn aanvragen, Wat moet ik regelen, Mijn registratie, Specialismen, Wat wilt u doen, Beheer) now owns its own store access, async state, and template. DashboardPage becomes pure composition. Extract the repeated RemoteData Success-narrowing pattern into successOf() and the dashboard sort/split logic into sortForDashboard/concepten/ingediend, both with tests. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { RemoteData, map2, map } from './remote-data';
|
||||
import { loading, failure, success } from '../testing/remote-data';
|
||||
import { RemoteData, map2, map, successOf } from './remote-data';
|
||||
import { loading, failure, empty, success } from '../testing/remote-data';
|
||||
|
||||
const loadingRd: RemoteData<string, number> = loading();
|
||||
const failureRd: RemoteData<string, number> = failure('x');
|
||||
@@ -21,3 +21,15 @@ describe('RemoteData combinators', () => {
|
||||
expect(map2(ok(2), ok(3), add)).toEqual({ tag: 'Success', value: 5 });
|
||||
});
|
||||
});
|
||||
|
||||
describe('successOf', () => {
|
||||
it('unwraps a Success value', () => {
|
||||
expect(successOf(ok(2))).toBe(2);
|
||||
});
|
||||
|
||||
it('is undefined for every other state', () => {
|
||||
expect(successOf(loadingRd)).toBeUndefined();
|
||||
expect(successOf(failureRd)).toBeUndefined();
|
||||
expect(successOf(empty())).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -80,3 +80,12 @@ export function andThen<E, A, B>(
|
||||
): RemoteData<E, B> {
|
||||
return rd.tag === 'Success' ? f(rd.value) : rd;
|
||||
}
|
||||
|
||||
/** Unwrap a Success value, or `undefined` for every other state. Used to narrow
|
||||
an `<app-async>` loaded slot: `<ng-template>` can't inherit a generic from a
|
||||
sibling host input (Angular only infers a structural directive's type
|
||||
parameter from an input on that same node), so the caller unwraps here
|
||||
instead of through `let-`. */
|
||||
export function successOf<E, T>(rd: RemoteData<E, T>): T | undefined {
|
||||
return rd.tag === 'Success' ? rd.value : undefined;
|
||||
}
|
||||
|
||||
@@ -11,3 +11,5 @@ export const loading = <E = never, T = never>(): RemoteData<E, T> => ({ tag: 'Lo
|
||||
export const success = <T, E = never>(value: T): RemoteData<E, T> => ({ tag: 'Success', value });
|
||||
|
||||
export const failure = <E, T = never>(error: E): RemoteData<E, T> => ({ tag: 'Failure', error });
|
||||
|
||||
export const empty = <E = never, T = never>(): RemoteData<E, T> => ({ tag: 'Empty' });
|
||||
|
||||
Reference in New Issue
Block a user