47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
/**
|
|
* Signup ViewModel Builder
|
|
*
|
|
* Transforms API DTOs into SignupViewModel for client-side state management.
|
|
* Deterministic, side-effect free, no business logic.
|
|
*/
|
|
|
|
import { SignupViewData } from '@/lib/view-data/SignupViewData';
|
|
import { SignupFormState, SignupUIState, SignupViewModel } from '@/lib/view-models/auth/SignupViewModel';
|
|
|
|
import { ViewModelBuilder } from "../../contracts/builders/ViewModelBuilder";
|
|
|
|
export class SignupViewModelBuilder implements ViewModelBuilder<any, any> {
|
|
build(input: any): any {
|
|
return SignupViewModelBuilder.build(input);
|
|
}
|
|
|
|
static build(
|
|
static build(viewData: SignupViewData): SignupViewModel {
|
|
const formState: SignupFormState = {
|
|
fields: {
|
|
firstName: { value: '', error: undefined, touched: false, validating: false },
|
|
lastName: { value: '', error: undefined, touched: false, validating: false },
|
|
email: { value: '', error: undefined, touched: false, validating: false },
|
|
password: { value: '', error: undefined, touched: false, validating: false },
|
|
confirmPassword: { value: '', error: undefined, touched: false, validating: false },
|
|
},
|
|
isValid: true,
|
|
isSubmitting: false,
|
|
submitError: undefined,
|
|
submitCount: 0,
|
|
};
|
|
|
|
const uiState: SignupUIState = {
|
|
showPassword: false,
|
|
showConfirmPassword: false,
|
|
};
|
|
|
|
return new SignupViewModel(
|
|
viewData.returnTo,
|
|
formState,
|
|
uiState,
|
|
false,
|
|
null
|
|
);
|
|
}
|
|
} |