diff options
Diffstat (limited to 'src/lib/auth/components/SwitchAccount.jsx')
| -rw-r--r-- | src/lib/auth/components/SwitchAccount.jsx | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/lib/auth/components/SwitchAccount.jsx b/src/lib/auth/components/SwitchAccount.jsx index 18c6076f..ad22da0f 100644 --- a/src/lib/auth/components/SwitchAccount.jsx +++ b/src/lib/auth/components/SwitchAccount.jsx @@ -69,7 +69,26 @@ const SwitchAccount = () => { validate(); } }, [isTerdaftar]); - + useEffect(() => { + const loadProfile = async () => { + const dataProfile = await addressApi({ + id: auth.parentId ? auth.parentId : auth.parent_id, + }); + if (dataProfile.companyType === 'Non PKP') { + 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) loadProfile(); + }, [auth, setValue]); useEffect(() => { updateForm('name', '-'); updateForm('email', 'example@mail.com'); @@ -125,6 +144,10 @@ const SwitchAccount = () => { toast.error('Terjadi kesalahan internal'); }; + const onSubmitHandlerCancel = async (values) => { + window.location.reload(); + }; + return ( <> <button @@ -191,6 +214,13 @@ const SwitchAccount = () => { <div className='flex justify-end mb-4 mr-4'> <button type='submit' + onClick={onSubmitHandlerCancel} + className='btn-red w-full sm:w-fit sm:ml-auto mt-6' + > + {mutation.isLoading ? 'Loading...' : 'Batal'} + </button> + <button + type='submit' onClick={onSubmitHandler} className='btn-yellow w-full sm:w-fit sm:ml-auto mt-6' > |
