From f0f002ff77481db91d264069d09f580d58001a8c Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 23 Sep 2024 13:15:02 +0700
Subject: <iman> update switch account

---
 src/lib/auth/components/SwitchAccount.jsx | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 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 b7b67864..bc9dee36 100644
--- a/src/lib/auth/components/SwitchAccount.jsx
+++ b/src/lib/auth/components/SwitchAccount.jsx
@@ -22,6 +22,7 @@ const SwitchAccount = () => {
   const [isChecked, setIsChecked] = useState(false);
   const [selectedValueBisnis, setSelectedValueBisnis] = useState('false');
   const [selectedValue, setSelectedValue] = useState('PKP');
+  const [buttonSubmitClick, setButtonSubmitClick] = useState(false);
   const { register, setValue, handleSubmit } = useForm({
     defaultValues: {
       email: '',
@@ -99,20 +100,22 @@ const SwitchAccount = () => {
   };
   console.log('auth', auth);
   const onSubmitHandler = async (values) => {
-    let data = form;
-    console.log('data', data);
+    // let data = { ...form, id: `${auth.partnerId}` };
+    const data = form;
     if (!isFormValid) {
-      console.log('masih ada yang belum valid');
       setNotValid(true);
+      setButtonSubmitClick(!buttonSubmitClick);
       return;
     } else {
+      setButtonSubmitClick(!buttonSubmitClick);
       setNotValid(false);
     }
     // if (!values.password) delete data.password;
+    console.log('data', data);
     const isUpdated = await switchAccountApi({ data });
     console.log('isupdate', isUpdated);
 
-    if (isUpdated.switch === 'Pending') {
+    if (isUpdated?.switch === 'Pending') {
       // setAuth(isUpdated.user);
       // setValue('password', '');
       toast.success('Berhasil mengubah akun', { duration: 1500 });
@@ -181,6 +184,7 @@ const SwitchAccount = () => {
             required={isTerdaftar}
             isPKP={isPKP}
             chekValid={notValid}
+            buttonSubmitClick={buttonSubmitClick}
           />
           <div className='flex justify-end mb-4 mr-4'>
             <button
-- 
cgit v1.2.3

