From ab39764b288b4d60923cc8cc6146ccdc1b4bfbac Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 11 Sep 2024 14:01:53 +0700 Subject: update switch acc --- .../modules/register/components/FormBisnis.tsx | 8 ++-- src/lib/auth/components/SwitchAccount.jsx | 49 ++++++++++++++++++++-- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/src-migrate/modules/register/components/FormBisnis.tsx b/src-migrate/modules/register/components/FormBisnis.tsx index 6631cb3b..73de60cb 100644 --- a/src-migrate/modules/register/components/FormBisnis.tsx +++ b/src-migrate/modules/register/components/FormBisnis.tsx @@ -296,7 +296,7 @@ const form: React.FC = ({ type, required, isPKP, chekValid }) => { className={` ${ type === 'bisnis' ? 'mt-6 grid grid-cols-1 gap-y-4' - : 'mt-6 grid grid-cols-2 gap-x-4 gap-y-2' + : 'mt-6 grid grid-cols-2 gap-x-4 gap-y-5 auto-rows-min' }`} onSubmit={handleSubmit} > @@ -332,11 +332,11 @@ const form: React.FC = ({ type, required, isPKP, chekValid }) => { )} -
+
-
+
= ({ type, required, isPKP, chekValid }) => { -
+
{ const auth = useAuth(); const [isOpen, setIsOpen] = useState(true); @@ -27,10 +30,14 @@ const SwitchAccount = () => { password: '', }, }); - + const mutation = useMutation({ + mutationFn: (data) => registerUser(data), + }); + const [notValid, setNotValid] = useState(false); const { form, isCheckedTNC, isValidCaptcha, errors, validate, updateForm } = useRegisterStore(); console.log('form', form); + const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]); useEffect(() => { const loadProfile = async () => { const dataProfile = await addressApi({ id: auth.partnerId }); @@ -82,6 +89,28 @@ const SwitchAccount = () => { setIsPKP(false); } }; + + const onSubmitHandler = async (values) => { + let data = values; + console.log('data', data); + if (!isFormValid) { + setNotValid(true); + return; + } else { + setNotValid(false); + } + // if (!values.password) delete data.password; + // const isUpdated = await editPersonalProfileApi({ data }); + + // if (isUpdated?.user) { + // setAuth(isUpdated.user); + // setValue('password', ''); + // toast.success('Berhasil mengubah profil', { duration: 1500 }); + // return; + // } + // toast.error('Terjadi kesalahan internal'); + }; + return ( <>
- +
)} +
+ +
); }; -- cgit v1.2.3