view data fixes
This commit is contained in:
@@ -1,44 +1,22 @@
|
||||
import { ViewModel } from "../../contracts/view-models/ViewModel";
|
||||
import type { SignupFormState, SignupUIState } from "./SignupInterfaces";
|
||||
|
||||
/**
|
||||
* Signup ViewModel
|
||||
*
|
||||
* Client-side state management for signup flow.
|
||||
* Immutable, class-based, contains only UI state.
|
||||
*/
|
||||
|
||||
export interface SignupFormField {
|
||||
value: string;
|
||||
error?: string;
|
||||
touched: boolean;
|
||||
validating: boolean;
|
||||
}
|
||||
|
||||
export interface SignupFormState {
|
||||
fields: {
|
||||
firstName: SignupFormField;
|
||||
lastName: SignupFormField;
|
||||
email: SignupFormField;
|
||||
password: SignupFormField;
|
||||
confirmPassword: SignupFormField;
|
||||
};
|
||||
isValid: boolean;
|
||||
isSubmitting: boolean;
|
||||
submitError?: string;
|
||||
submitCount: number;
|
||||
}
|
||||
|
||||
export interface SignupUIState {
|
||||
showPassword: boolean;
|
||||
showConfirmPassword: boolean;
|
||||
}
|
||||
|
||||
export class SignupViewModel {
|
||||
export class SignupViewModel extends ViewModel {
|
||||
constructor(
|
||||
public readonly returnTo: string,
|
||||
public readonly formState: SignupFormState,
|
||||
public readonly uiState: SignupUIState,
|
||||
public readonly mutationPending: boolean = false,
|
||||
public readonly mutationError: string | null = null
|
||||
) {}
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
withFormState(formState: SignupFormState): SignupViewModel {
|
||||
return new SignupViewModel(
|
||||
@@ -77,4 +55,4 @@ export class SignupViewModel {
|
||||
get submitError(): string | undefined {
|
||||
return this.formState.submitError || this.mutationError || undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user