view data fixes
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
export interface ForgotPasswordFormField {
|
||||
value: string;
|
||||
error?: string;
|
||||
touched: boolean;
|
||||
validating: boolean;
|
||||
}
|
||||
|
||||
export interface ForgotPasswordFormState {
|
||||
fields: {
|
||||
email: ForgotPasswordFormField;
|
||||
};
|
||||
isValid: boolean;
|
||||
isSubmitting: boolean;
|
||||
submitError?: string;
|
||||
submitCount: number;
|
||||
}
|
||||
@@ -1,28 +1,13 @@
|
||||
import { ViewModel } from "../../contracts/view-models/ViewModel";
|
||||
import type { ForgotPasswordFormState } from "./ForgotPasswordInterfaces";
|
||||
|
||||
/**
|
||||
* Forgot Password ViewModel
|
||||
*
|
||||
* Client-side state management for forgot password flow.
|
||||
* Immutable, class-based, contains only UI state.
|
||||
*/
|
||||
|
||||
export interface ForgotPasswordFormField {
|
||||
value: string;
|
||||
error?: string;
|
||||
touched: boolean;
|
||||
validating: boolean;
|
||||
}
|
||||
|
||||
export interface ForgotPasswordFormState {
|
||||
fields: {
|
||||
email: ForgotPasswordFormField;
|
||||
};
|
||||
isValid: boolean;
|
||||
isSubmitting: boolean;
|
||||
submitError?: string;
|
||||
submitCount: number;
|
||||
}
|
||||
|
||||
export class ForgotPasswordViewModel {
|
||||
export class ForgotPasswordViewModel extends ViewModel {
|
||||
constructor(
|
||||
public readonly returnTo: string,
|
||||
public readonly formState: ForgotPasswordFormState,
|
||||
@@ -31,7 +16,9 @@ export class ForgotPasswordViewModel {
|
||||
public readonly magicLink: string | null = null,
|
||||
public readonly mutationPending: boolean = false,
|
||||
public readonly mutationError: string | null = null
|
||||
) {}
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
withFormState(formState: ForgotPasswordFormState): ForgotPasswordViewModel {
|
||||
return new ForgotPasswordViewModel(
|
||||
@@ -76,4 +63,4 @@ export class ForgotPasswordViewModel {
|
||||
get submitError(): string | undefined {
|
||||
return this.formState.submitError || this.mutationError || undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
23
apps/website/lib/view-models/auth/LoginInterfaces.ts
Normal file
23
apps/website/lib/view-models/auth/LoginInterfaces.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
export interface LoginFormField {
|
||||
value: string | boolean;
|
||||
error?: string;
|
||||
touched: boolean;
|
||||
validating: boolean;
|
||||
}
|
||||
|
||||
export interface LoginFormState {
|
||||
fields: {
|
||||
email: LoginFormField;
|
||||
password: LoginFormField;
|
||||
rememberMe: LoginFormField;
|
||||
};
|
||||
isValid: boolean;
|
||||
isSubmitting: boolean;
|
||||
submitError?: string;
|
||||
submitCount: number;
|
||||
}
|
||||
|
||||
export interface LoginUIState {
|
||||
showPassword: boolean;
|
||||
showErrorDetails: boolean;
|
||||
}
|
||||
@@ -1,35 +1,13 @@
|
||||
import { ViewModel } from "../../contracts/view-models/ViewModel";
|
||||
import type { LoginFormState, LoginUIState } from "./LoginInterfaces";
|
||||
|
||||
/**
|
||||
* Login ViewModel
|
||||
*
|
||||
* Client-side state management for login flow.
|
||||
* Immutable, class-based, contains only UI state.
|
||||
*/
|
||||
|
||||
export interface LoginFormField {
|
||||
value: string | boolean;
|
||||
error?: string;
|
||||
touched: boolean;
|
||||
validating: boolean;
|
||||
}
|
||||
|
||||
export interface LoginFormState {
|
||||
fields: {
|
||||
email: LoginFormField;
|
||||
password: LoginFormField;
|
||||
rememberMe: LoginFormField;
|
||||
};
|
||||
isValid: boolean;
|
||||
isSubmitting: boolean;
|
||||
submitError?: string;
|
||||
submitCount: number;
|
||||
}
|
||||
|
||||
export interface LoginUIState {
|
||||
showPassword: boolean;
|
||||
showErrorDetails: boolean;
|
||||
}
|
||||
|
||||
export class LoginViewModel {
|
||||
export class LoginViewModel extends ViewModel {
|
||||
constructor(
|
||||
public readonly returnTo: string,
|
||||
public readonly hasInsufficientPermissions: boolean,
|
||||
@@ -37,7 +15,9 @@ export class LoginViewModel {
|
||||
public readonly uiState: LoginUIState,
|
||||
public readonly mutationPending: boolean = false,
|
||||
public readonly mutationError: string | null = null
|
||||
) {}
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
// Immutable updates
|
||||
withFormState(formState: LoginFormState): LoginViewModel {
|
||||
@@ -93,4 +73,4 @@ export class LoginViewModel {
|
||||
get formFields() {
|
||||
return this.formState.fields;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
22
apps/website/lib/view-models/auth/ResetPasswordInterfaces.ts
Normal file
22
apps/website/lib/view-models/auth/ResetPasswordInterfaces.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
export interface ResetPasswordFormField {
|
||||
value: string;
|
||||
error?: string;
|
||||
touched: boolean;
|
||||
validating: boolean;
|
||||
}
|
||||
|
||||
export interface ResetPasswordFormState {
|
||||
fields: {
|
||||
newPassword: ResetPasswordFormField;
|
||||
confirmPassword: ResetPasswordFormField;
|
||||
};
|
||||
isValid: boolean;
|
||||
isSubmitting: boolean;
|
||||
submitError?: string;
|
||||
submitCount: number;
|
||||
}
|
||||
|
||||
export interface ResetPasswordUIState {
|
||||
showPassword: boolean;
|
||||
showConfirmPassword: boolean;
|
||||
}
|
||||
@@ -1,34 +1,13 @@
|
||||
import { ViewModel } from "../../contracts/view-models/ViewModel";
|
||||
import type { ResetPasswordFormState, ResetPasswordUIState } from "./ResetPasswordInterfaces";
|
||||
|
||||
/**
|
||||
* Reset Password ViewModel
|
||||
*
|
||||
* Client-side state management for reset password flow.
|
||||
* Immutable, class-based, contains only UI state.
|
||||
*/
|
||||
|
||||
export interface ResetPasswordFormField {
|
||||
value: string;
|
||||
error?: string;
|
||||
touched: boolean;
|
||||
validating: boolean;
|
||||
}
|
||||
|
||||
export interface ResetPasswordFormState {
|
||||
fields: {
|
||||
newPassword: ResetPasswordFormField;
|
||||
confirmPassword: ResetPasswordFormField;
|
||||
};
|
||||
isValid: boolean;
|
||||
isSubmitting: boolean;
|
||||
submitError?: string;
|
||||
submitCount: number;
|
||||
}
|
||||
|
||||
export interface ResetPasswordUIState {
|
||||
showPassword: boolean;
|
||||
showConfirmPassword: boolean;
|
||||
}
|
||||
|
||||
export class ResetPasswordViewModel {
|
||||
export class ResetPasswordViewModel extends ViewModel {
|
||||
constructor(
|
||||
public readonly token: string,
|
||||
public readonly returnTo: string,
|
||||
@@ -38,7 +17,9 @@ export class ResetPasswordViewModel {
|
||||
public readonly successMessage: string | null = null,
|
||||
public readonly mutationPending: boolean = false,
|
||||
public readonly mutationError: string | null = null
|
||||
) {}
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
withFormState(formState: ResetPasswordFormState): ResetPasswordViewModel {
|
||||
return new ResetPasswordViewModel(
|
||||
@@ -99,4 +80,4 @@ export class ResetPasswordViewModel {
|
||||
get submitError(): string | undefined {
|
||||
return this.formState.submitError || this.mutationError || undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
25
apps/website/lib/view-models/auth/SignupInterfaces.ts
Normal file
25
apps/website/lib/view-models/auth/SignupInterfaces.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
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;
|
||||
}
|
||||
@@ -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