Files
gridpilot.gg/apps/website/lib/builders/view-data/SignupViewDataBuilder.ts
Marc Mintel 046852703f
Some checks failed
Contract Testing / contract-tests (pull_request) Failing after 5m51s
Contract Testing / contract-snapshot (pull_request) Has been skipped
view data fixes
2026-01-24 12:14:08 +01:00

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>;