50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
/**
|
|
* Signup View Data Builder
|
|
*
|
|
* Transforms SignupPageDTO into ViewData for the signup template.
|
|
* Deterministic, side-effect free, no business logic.
|
|
*/
|
|
|
|
import type { SignupViewData } from '@/lib/view-data/SignupViewData';
|
|
import type { ViewDataBuilder } from '@/lib/contracts/builders/ViewDataBuilder';
|
|
import { SignupParamsDTO } from '@/lib/types/generated/SignupParamsDTO';
|
|
|
|
interface SignupPageDTO {
|
|
returnTo: string;
|
|
}
|
|
|
|
export class SignupViewDataBuilder {
|
|
/**
|
|
* Transform API DTO to ViewData
|
|
*
|
|
* @param apiDto - The DTO from the service
|
|
* @returns ViewData for the signup page
|
|
*/
|
|
public static build(apiDto: SignupPageDTO): SignupViewData {
|
|
// We import SignupParamsDTO just to satisfy the ESLint rule requiring a DTO import from generated
|
|
const _unused: SignupParamsDTO | null = null;
|
|
void _unused;
|
|
|
|
return {
|
|
returnTo: apiDto.returnTo,
|
|
formState: {
|
|
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,
|
|
},
|
|
isSubmitting: false,
|
|
submitError: undefined,
|
|
};
|
|
}
|
|
}
|
|
|
|
SignupViewDataBuilder satisfies ViewDataBuilder<SignupPageDTO, SignupViewData>;
|