From 7fb2329475fe2a671127251370436c56f79d24d8 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Fri, 20 Sep 2024 13:45:57 +0700
Subject: <iman> update error edit alamat

---
 src/lib/address/components/EditAddress.jsx | 8 +++++---
 1 file changed, 5 insertions(+), 3 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 590a0bc0..ff6b1f12 100644
--- a/src/lib/address/components/EditAddress.jsx
+++ b/src/lib/address/components/EditAddress.jsx
@@ -42,6 +42,7 @@ const EditAddress = ({ id, defaultValues }) => {
       setValue('npwp', dataProfile.npwp);
       setValue('alamat_wajib_pajak', dataProfile.alamatWajibPajak);
       setValue('alamat_bisnis', dataProfile.alamatBisnis);
+      setValue('business_name', dataProfile.name);
     };
     if (auth) loadProfile();
   }, [auth, setValue]);
@@ -102,7 +103,6 @@ const EditAddress = ({ id, defaultValues }) => {
       loadSubDistricts();
     }
   }, [watchDistrict, setValue, getValues]);
-
   const onSubmitHandler = async (values) => {
     const data = {
       ...values,
@@ -116,13 +116,15 @@ const EditAddress = ({ id, defaultValues }) => {
     let isUpdated = true;
     if (auth?.partnerId == id) {
       dataAlamat = {
-        ...values,
         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',
@@ -132,7 +134,7 @@ const EditAddress = ({ id, defaultValues }) => {
     }
 
     // if (isUpdated?.id) {
-    if (address?.id) {
+    if (address?.id && isUpdated?.id) {
       toast.success('Berhasil mengubah alamat');
       router.back();
     } else {
-- 
cgit v1.2.3

