diff options
author | Samuel Newman <mozzius@protonmail.com> | 2025-02-24 12:44:21 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-24 12:44:21 -0800 |
commit | ae9176c9c2112641c6484ac4b50edfbd94d29661 (patch) | |
tree | 14bafaa11ed4a2dfb5a7b2ed722bcf2991896361 /src/screens/Signup/state.ts | |
parent | 3d954a00e009f85433e4b5f43d0d1960c8f6c639 (diff) | |
download | voidsky-ae9176c9c2112641c6484ac4b50edfbd94d29661.tar.zst |
Basic minimum password requirements, plus field-specific errors (#7811)
* add min password requirement * add field specific errors * move email tld check to after other email checks * add password length check to change password dialog * Update src/view/com/modals/ChangePassword.tsx Co-authored-by: Hailey <me@haileyok.com> * Update src/screens/Signup/StepInfo/index.tsx Co-authored-by: Hailey <me@haileyok.com> * fix lint --------- Co-authored-by: Hailey <me@haileyok.com>
Diffstat (limited to 'src/screens/Signup/state.ts')
-rw-r--r-- | src/screens/Signup/state.ts | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/screens/Signup/state.ts b/src/screens/Signup/state.ts index 4addf3580..3daf36a9b 100644 --- a/src/screens/Signup/state.ts +++ b/src/screens/Signup/state.ts @@ -31,6 +31,13 @@ type SubmitTask = { mutableProcessed: boolean // OK to mutate assuming it's never read in render. } +type ErrorField = + | 'invite-code' + | 'email' + | 'handle' + | 'password' + | 'date-of-birth' + export type SignupState = { hasPrev: boolean activeStep: SignupStep @@ -45,6 +52,7 @@ export type SignupState = { handle: string error: string + errorField?: ErrorField isLoading: boolean pendingSubmit: null | SubmitTask @@ -62,7 +70,8 @@ export type SignupAction = | {type: 'setDateOfBirth'; value: Date} | {type: 'setInviteCode'; value: string} | {type: 'setHandle'; value: string} - | {type: 'setError'; value: string} + | {type: 'setError'; value: string; field?: ErrorField} + | {type: 'clearError'} | {type: 'setIsLoading'; value: boolean} | {type: 'submit'; task: SubmitTask} @@ -80,6 +89,7 @@ export const initialState: SignupState = { inviteCode: '', error: '', + errorField: undefined, isLoading: false, pendingSubmit: null, @@ -102,6 +112,7 @@ export function reducer(s: SignupState, a: SignupAction): SignupState { LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) next.activeStep-- next.error = '' + next.errorField = undefined } break } @@ -110,6 +121,7 @@ export function reducer(s: SignupState, a: SignupAction): SignupState { LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) next.activeStep++ next.error = '' + next.errorField = undefined } break } @@ -156,6 +168,12 @@ export function reducer(s: SignupState, a: SignupAction): SignupState { } case 'setError': { next.error = a.value + next.errorField = a.field + break + } + case 'clearError': { + next.error = '' + next.errorField = undefined break } case 'submit': { |