diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-08-26 10:28:15 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-08-26 10:28:15 +0700 |
| commit | f0cde08a3fda95b1738a765358022241aea404bf (patch) | |
| tree | c2cf2cb3e07154d04672f3b9d0667753f8487764 /src-migrate/modules/register/stores/useRegisterStore.ts | |
| parent | 0bca1bfb2bc7e52a31dde39602dd599d7c640e73 (diff) | |
<iman> update logic new register validation
Diffstat (limited to 'src-migrate/modules/register/stores/useRegisterStore.ts')
| -rw-r--r-- | src-migrate/modules/register/stores/useRegisterStore.ts | 68 |
1 files changed, 24 insertions, 44 deletions
diff --git a/src-migrate/modules/register/stores/useRegisterStore.ts b/src-migrate/modules/register/stores/useRegisterStore.ts index 75d2ab34..7bed1833 100644 --- a/src-migrate/modules/register/stores/useRegisterStore.ts +++ b/src-migrate/modules/register/stores/useRegisterStore.ts @@ -5,7 +5,6 @@ import { boolean, ZodError } from 'zod'; type State = { form: RegisterProps; - formBisnis: RegisterProps; errors: { [key in keyof RegisterProps]?: string; }; @@ -16,36 +15,16 @@ type State = { type Action = { updateForm: (name: string, value: string) => void; - updateFormBisnis: (name: string, value: string) => void; updateValidCaptcha: (value: boolean) => void; toggleCheckTNC: () => void; openTNC: () => void; closeTNC: () => void; validate: () => void; - validateFormBisnis: () => void; + resetForm: () => void; }; export const useRegisterStore = create<State & Action>((set, get) => ({ form: { - business_name: '', - company_type_id: '', - name: '', - email: '', - email_partner: '', - password: '', - phone: '', - sppkp_document: '', - npwp_document: '', - nameWajibPajak: '', - industry_id: '', - badanUsaha: '', - jenisUsaha: '', - npwp: '', - nama_wajib_pajak : '', - is_pkp: '', - type_acc:'' - }, - formBisnis: { company_type_id: '', business_name: '', name: '', @@ -56,19 +35,15 @@ export const useRegisterStore = create<State & Action>((set, get) => ({ phone: '', sppkp_document: '', npwp_document: '', - nameWajibPajak: '', industry_id: '', - badanUsaha: '', - jenisUsaha: '', npwp: '', - is_pkp:'', - type_acc:'' + is_pkp: '', + type_acc:'', + is_terdaftar:'' }, updateForm: (name, value) => set((state) => ({ form: { ...state.form, [name]: value } })), - updateFormBisnis: (name, value) => - set((state) => ({ formBisnis: { ...state.formBisnis, [name]: value } })), errors: {}, validate: () => { @@ -85,21 +60,6 @@ export const useRegisterStore = create<State & Action>((set, get) => ({ } } }, - - validateFormBisnis: () => { - try { - registerSchema.parse(get().formBisnis); - set({ errors: {} }); - } catch (error) { - if (error instanceof ZodError) { - const errors: State['errors'] = {}; - error.errors.forEach( - (e) => (errors[e.path[0] as keyof RegisterProps] = e.message) - ); - set({ errors }); - } - } - }, isCheckedTNC: false, toggleCheckTNC: () => set((state) => ({ isCheckedTNC: !state.isCheckedTNC })), @@ -110,4 +70,24 @@ export const useRegisterStore = create<State & Action>((set, get) => ({ isValidCaptcha: false, updateValidCaptcha: (value) => set(() => ({ isValidCaptcha: value })), + + resetForm: () => set({ + form: { + company_type_id: '', + business_name: '', + name: '', + nama_wajib_pajak : '', + email: '', + email_partner: '', + password: '', + phone: '', + sppkp_document: '', + npwp_document: '', + industry_id: '', + npwp: '', + is_pkp: '', + type_acc:'', + is_terdaftar:'' + }, + }), })); |
