From fad165af76bb008076e96199f173fbe27b7835a8 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 18 Sep 2024 17:18:47 +0700
Subject: <iman> update alamat yang sama

---
 src-migrate/modules/register/components/FormBisnis.tsx | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

(limited to 'src-migrate/modules/register/components/FormBisnis.tsx')

diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx
index 70ed6bee..bf00c28e 100644
--- a/src-migrate/modules/register/components/FormBisnis.tsx
+++ b/src-migrate/modules/register/components/FormBisnis.tsx
@@ -48,6 +48,7 @@ const form: React.FC<FormProps> = ({
   buttonSubmitClick,
 }) => {
   const { form, errors, updateForm, validate } = useRegisterStore();
+  console.log('form', form);
   const { control, watch, setValue } = useForm();
   const [selectedCategory, setSelectedCategory] = useState<string>('');
   const [isChekBox, setIsChekBox] = useState<boolean>(false);
@@ -128,9 +129,23 @@ const form: React.FC<FormProps> = ({
 
   const handleInputChange = (event: ChangeEvent<HTMLInputElement>) => {
     const { name, value } = event.target;
-    updateForm('type_acc', `business`);
+
+    updateForm('type_acc', 'business');
     updateForm('is_pkp', `${isPKP}`);
+
+    // Update form dengan nilai terbaru dari input yang berubah
     updateForm(name, value);
+
+    // Jika checkbox aktif, sinkronisasi alamat_wajib_pajak dengan alamat_bisnis
+    if (isChekBox) {
+      if (name === 'alamat_wajib_pajak') {
+        updateForm('alamat_bisnis', value);
+      } else if (name === 'alamat_bisnis') {
+        updateForm('alamat_wajib_pajak', value);
+      }
+    }
+
+    // Validasi setelah perubahan dilakukan
     validate();
   };
 
@@ -188,6 +203,7 @@ const form: React.FC<FormProps> = ({
   useEffect(() => {
     if (isChekBox) {
       updateForm('isChekBox', 'true');
+      updateForm('alamat_wajib_pajak', `${form.alamat_bisnis}`);
       validate();
     } else {
       updateForm('isChekBox', 'false');
-- 
cgit v1.2.3

