diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-09-23 13:15:02 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-09-23 13:15:02 +0700 |
| commit | f0f002ff77481db91d264069d09f580d58001a8c (patch) | |
| tree | cb3b916a1688c17407d1a831e36c12c6021feac3 /src/lib/auth/components | |
| parent | c13bb5c6f78032695b24cf8a6c23942eb465c6d5 (diff) | |
<iman> update switch account
Diffstat (limited to 'src/lib/auth/components')
| -rw-r--r-- | src/lib/auth/components/SwitchAccount.jsx | 12 |
1 files changed, 8 insertions, 4 deletions
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 |
