From 0a5fdb5d712a23164d9da0758d4f88ab70ef1f2e Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 30 Sep 2024 17:43:38 +0700
Subject: <iman> update register kesalahan bisa ubah npwp

---
 src/lib/address/components/EditAddress.jsx | 38 +++++++++++++++---------------
 1 file changed, 19 insertions(+), 19 deletions(-)

(limited to 'src/lib/address/components/EditAddress.jsx')

diff --git a/src/lib/address/components/EditAddress.jsx b/src/lib/address/components/EditAddress.jsx
index ff6b1f12..53368947 100644
--- a/src/lib/address/components/EditAddress.jsx
+++ b/src/lib/address/components/EditAddress.jsx
@@ -45,7 +45,7 @@ const EditAddress = ({ id, defaultValues }) => {
       setValue('business_name', dataProfile.name);
     };
     if (auth) loadProfile();
-  }, [auth, setValue]);
+  }, [auth?.parentId]);
 
   useEffect(() => {
     const loadCities = async () => {
@@ -111,30 +111,30 @@ const EditAddress = ({ id, defaultValues }) => {
       district_id: values.district,
       sub_district_id: values.subDistrict,
     };
+    if (!auth.company) {
+      data.alamat_lengkap_text = values.street;
+    }
     const address = await editAddressApi({ id, data });
     let dataAlamat;
     let isUpdated = true;
-    if (auth?.partnerId == id) {
-      dataAlamat = {
-        id_user: auth.partnerId,
-        company_type_id: values.companyType,
-        industry_id: values.industry,
-        tax_name: values.taxName,
-        alamat_lengkap_text: values.alamat_wajib_pajak,
-        street: values.street,
-        business_name: values.business_name,
-        name: values.business_name,
-        npwp: values.npwp,
-      };
-      isUpdated = await odooApi(
-        'PUT',
-        `/api/v1/partner/${auth.parentId}`,
-        dataAlamat
-      );
+    if (auth.company) {
+      if (auth?.partnerId == id) {
+        dataAlamat = {
+          id_user: auth.partnerId,
+          alamat_lengkap_text: values.alamat_wajib_pajak,
+          street: values.street,
+        };
+        console.log('dataAlamat', dataAlamat);
+        isUpdated = await odooApi(
+          'PUT',
+          `/api/v1/partner/${auth.parentId}`,
+          dataAlamat
+        );
+      }
     }
 
     // if (isUpdated?.id) {
-    if (address?.id && isUpdated?.id) {
+    if (address?.id && auth.company ? isUpdated?.id : true) {
       toast.success('Berhasil mengubah alamat');
       router.back();
     } else {
-- 
cgit v1.2.3

