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


From 6d5ace9505543bcfbc5c830b86613fef00101cbd Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 18 Sep 2024 17:20:01 +0700
Subject: <iman> delete console log

---
 src-migrate/modules/register/components/FormBisnis.tsx | 1 -
 1 file changed, 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 bf00c28e..042bf507 100644
--- a/src-migrate/modules/register/components/FormBisnis.tsx
+++ b/src-migrate/modules/register/components/FormBisnis.tsx
@@ -48,7 +48,6 @@ 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);
-- 
cgit v1.2.3


From c651d654c2c87d26aab184025b7d0e4d8e74e65f Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 19 Sep 2024 10:11:47 +0700
Subject: <iman> fix otp send 3 times

---
 .../modules/register/components/FormBisnis.tsx     | 56 +---------------------
 1 file changed, 2 insertions(+), 54 deletions(-)

(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 042bf507..5ee19e58 100644
--- a/src-migrate/modules/register/components/FormBisnis.tsx
+++ b/src-migrate/modules/register/components/FormBisnis.tsx
@@ -256,15 +256,11 @@ const form: React.FC<FormProps> = ({
       validate(); // Perform form validation
     }
   };
-
-  const mutation = useMutation({
-    mutationFn: (data: RegisterProps) => registerUser(data),
-  });
+  const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]);
 
   useEffect(() => {
     const loadIndustries = async () => {
-      const response = await mutation.mutateAsync(form);
-      if (!response?.register) {
+      if (!isFormValid) {
         const options: ScrollIntoViewOptions = {
           behavior: 'smooth',
           block: 'center',
@@ -314,53 +310,6 @@ const form: React.FC<FormProps> = ({
     };
     loadIndustries();
   }, [buttonSubmitClick, chekValid]);
-
-  const handleSubmit = async (e: ChangeEvent<HTMLFormElement>) => {
-    e.preventDefault();
-
-    const response = await mutation.mutateAsync(form);
-
-    if (response?.register === true) {
-      const urlParams = new URLSearchParams({
-        activation: 'otp',
-        email: form.email,
-        redirect: (router.query?.next || '/') as string,
-      });
-      router.push(`${router.route}?${urlParams}`);
-    }
-
-    const toastProps: UseToastOptions = {
-      duration: 5000,
-      isClosable: true,
-      position: 'top',
-    };
-
-    switch (response?.reason) {
-      case 'EMAIL_USED':
-        toast({
-          ...toastProps,
-          title: 'Email sudah digunakan',
-          status: 'warning',
-        });
-        break;
-      case 'NOT_ACTIVE':
-        const activationUrl = `${router.route}?activation=email`;
-        toast({
-          ...toastProps,
-          title: 'Akun belum aktif',
-          description: (
-            <>
-              Akun sudah terdaftar namun belum aktif.{' '}
-              <Link href={activationUrl} className='underline'>
-                Klik untuk aktivasi akun
-              </Link>
-            </>
-          ),
-          status: 'warning',
-        });
-        break;
-    }
-  };
   return (
     <>
       <BottomPopup
@@ -386,7 +335,6 @@ const form: React.FC<FormProps> = ({
             ? 'mt-6 grid grid-cols-1 gap-y-4'
             : 'mt-6 grid grid-cols-2 gap-x-4 gap-y-2'
         }`}
-        onSubmit={handleSubmit}
       >
         <div>
           <label htmlFor='email' className='font-bold'>
-- 
cgit v1.2.3

