From 31ef67c8c2c3d80bf0c0cc040e551b4a45c3dedc Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Fri, 27 Sep 2024 15:36:39 +0700
Subject: <iman> update form bisnis to switch account

---
 src/lib/auth/components/SwitchAccount.jsx | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

(limited to 'src/lib/auth/components/SwitchAccount.jsx')

diff --git a/src/lib/auth/components/SwitchAccount.jsx b/src/lib/auth/components/SwitchAccount.jsx
index 14ad7e8a..fa1d3924 100644
--- a/src/lib/auth/components/SwitchAccount.jsx
+++ b/src/lib/auth/components/SwitchAccount.jsx
@@ -74,17 +74,18 @@ const SwitchAccount = () => {
       const dataProfile = await addressApi({
         id: auth.parentId ? auth.parentId : auth.parent_id,
       });
-      if (dataProfile.companyType === 'Non PKP') {
+      console.log('dataProfile', dataProfile);
+      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);
+      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();
@@ -214,17 +215,17 @@ 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'
+              onClick={onSubmitHandler}
+              className='btn-yellow w-full sm:w-fit sm:ml-auto mt-6'
             >
-              {mutation.isLoading ? 'Loading...' : 'Batal'}
+              {mutation.isLoading ? 'Loading...' : 'Simpan Perubahan'}
             </button>
             <button
               type='submit'
-              onClick={onSubmitHandler}
-              className='btn-yellow w-full sm:w-fit sm:ml-auto mt-6'
+              onClick={onSubmitHandlerCancel}
+              className='btn-red w-full sm:w-fit sm:ml-auto mt-6'
             >
-              {mutation.isLoading ? 'Loading...' : 'Simpan Perubahan'}
+              {mutation.isLoading ? 'Loading...' : 'Batal'}
             </button>
           </div>
         </div>
-- 
cgit v1.2.3

