37 lines
854 B
TypeScript
37 lines
854 B
TypeScript
import { patchState, signalStore, withMethods, withState } from '@ngrx/signals';
|
|
|
|
export type StartingPointState = {
|
|
name: string;
|
|
gender: Gender;
|
|
afterHighSchool: AfterHighSchool;
|
|
};
|
|
|
|
export enum Gender {
|
|
Undefined = '',
|
|
Male = 'male',
|
|
Female = 'female',
|
|
}
|
|
|
|
export enum AfterHighSchool {
|
|
Undefined = '',
|
|
College = 'college',
|
|
Workforce = 'workforce',
|
|
}
|
|
|
|
const initialState: StartingPointState = {
|
|
name: '',
|
|
gender: Gender.Undefined,
|
|
afterHighSchool: AfterHighSchool.Undefined,
|
|
};
|
|
|
|
export const StartingPointStateStore = signalStore(
|
|
withState(initialState),
|
|
withMethods(store => ({
|
|
updateState: ({ name, gender, afterHighSchool }: Partial<StartingPointState>) =>
|
|
patchState(store, () => ({
|
|
name: name ?? '',
|
|
gender: gender ?? Gender.Undefined,
|
|
afterHighSchool: afterHighSchool ?? AfterHighSchool.Undefined,
|
|
})),
|
|
}))
|
|
);
|