From c651d654c2c87d26aab184025b7d0e4d8e74e65f Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 19 Sep 2024 10:11:47 +0700 Subject: fix otp send 3 times --- src-migrate/modules/register/components/Form.tsx | 57 +--------------------- .../modules/register/components/FormBisnis.tsx | 56 +-------------------- 2 files changed, 4 insertions(+), 109 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/register/components/Form.tsx b/src-migrate/modules/register/components/Form.tsx index cd0b4343..38e9c810 100644 --- a/src-migrate/modules/register/components/Form.tsx +++ b/src-migrate/modules/register/components/Form.tsx @@ -41,15 +41,9 @@ const Form: React.FC = ({ updateForm(name, value); validate(); }; - - const mutation = useMutation({ - mutationFn: (data: RegisterProps) => registerUser(data), - }); - useEffect(() => { const loadIndustries = async () => { - const response = await mutation.mutateAsync(form); - if (!response?.register) { + if (!isFormValid) { const options: ScrollIntoViewOptions = { behavior: 'smooth', block: 'center', @@ -78,55 +72,8 @@ const Form: React.FC = ({ loadIndustries(); }, [buttonSubmitClick, chekValid]); - const handleSubmit = async (e: ChangeEvent) => { - 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.{' '} - - Klik untuk aktivasi akun - - - ), - status: 'warning', - }); - break; - } - }; - return ( -
+