From 0bca1bfb2bc7e52a31dde39602dd599d7c640e73 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Sat, 24 Aug 2024 08:46:44 +0700
Subject: <iman> update new register

---
 .../register/components/RegistrasiBisnis.tsx       | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)

(limited to 'src-migrate/modules/register/components/RegistrasiBisnis.tsx')

diff --git a/src-migrate/modules/register/components/RegistrasiBisnis.tsx b/src-migrate/modules/register/components/RegistrasiBisnis.tsx
index 12ec7ba2..6ace27f9 100644
--- a/src-migrate/modules/register/components/RegistrasiBisnis.tsx
+++ b/src-migrate/modules/register/components/RegistrasiBisnis.tsx
@@ -86,6 +86,42 @@ const RegistrasiBisnis = () => {
   const handleSubmit = async () => {
     console.log("form",form)
     console.log("form Bisnis",formBisnis)
+    const response = await mutation.mutateAsync(formBisnis)
+
+    console.log("response",response)
+
+    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
+    }
+
+    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 (
     <>
-- 
cgit v1.2.3

