diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-10-01 13:31:45 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-10-01 13:31:45 +0700 |
| commit | 09e45bafb7d4a0522643ee3b188ae18b82fb27bb (patch) | |
| tree | 690729565095bcef73c3f2ac3739d91633c11ba8 /src/lib | |
| parent | 693645910dab9e3f36600c9c542249455c1e1369 (diff) | |
<iman> update switch account
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/auth/components/SwitchAccount.jsx | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/src/lib/auth/components/SwitchAccount.jsx b/src/lib/auth/components/SwitchAccount.jsx index 12d00890..9adcc726 100644 --- a/src/lib/auth/components/SwitchAccount.jsx +++ b/src/lib/auth/components/SwitchAccount.jsx @@ -39,8 +39,15 @@ const SwitchAccount = ({ company_type }) => { mutationFn: (data) => registerUser(data), }); const [notValid, setNotValid] = useState(false); - const { form, isCheckedTNC, isValidCaptcha, errors, validate, updateForm } = - useRegisterStore(); + const { + form, + isCheckedTNC, + isValidCaptcha, + errors, + validate, + updateForm, + resetForm, + } = useRegisterStore(); const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]); useEffect(() => { const loadProfile = async () => { @@ -79,15 +86,17 @@ const SwitchAccount = ({ company_type }) => { if (dataProfile?.companyType === 'nonpkp') { setSelectedValue('PKP'); } - updateForm('email_partner', dataProfile?.email_partner); - updateForm('business_name', dataProfile?.name); - updateForm('industry_id', `${dataProfile?.industryId}`); - updateForm('company_type_id', `${dataProfile?.companyTypeId}`); - updateForm('nama_wajib_pajak', dataProfile?.taxName); - updateForm('npwp', dataProfile?.npwp); - updateForm('alamat_wajib_pajak', dataProfile?.alamatWajibPajak); - updateForm('alamat_bisnis', dataProfile?.alamatBisnis); - validate(); + if (auth?.company) { + updateForm('email_partner', dataProfile?.email_partner); + updateForm('business_name', dataProfile?.name); + updateForm('industry_id', `${dataProfile?.industryId}`); + updateForm('company_type_id', `${dataProfile?.companyTypeId}`); + updateForm('nama_wajib_pajak', dataProfile?.taxName); + updateForm('npwp', dataProfile?.npwp); + updateForm('alamat_wajib_pajak', dataProfile?.alamatWajibPajak); + updateForm('alamat_bisnis', dataProfile?.alamatBisnis); + validate(); + } }; if (auth) loadProfile(); }, [auth, setValue]); @@ -97,9 +106,10 @@ const SwitchAccount = ({ company_type }) => { updateForm('password', 'example@mail.com'); updateForm('phone', '081234567890'); validate(); - }, []); + }, [buttonSubmitClick, changeConfirmation]); const handleChangeBisnis = (value) => { + resetForm(); setSelectedValueBisnis(value); if (value === 'true') { validate(); @@ -121,9 +131,12 @@ const SwitchAccount = ({ company_type }) => { } }; const onSubmitHandler = async (values) => { + console.log('error', errors); + console.log('form', form); setChangeConfirmation(false); // let data = { ...form, id: `${auth.partnerId}` }; const data = form; + console.log('data', data); if (!isFormValid) { setNotValid(true); setButtonSubmitClick(!buttonSubmitClick); |
