From 00df44e6f25eaeabc56ebba8b4e9b1cb692928d7 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 20 Aug 2024 10:27:32 +0700
Subject: <iman> add new register

---
 src-migrate/modules/register/components/Form.tsx | 89 +++++++++++-------------
 1 file changed, 42 insertions(+), 47 deletions(-)

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

diff --git a/src-migrate/modules/register/components/Form.tsx b/src-migrate/modules/register/components/Form.tsx
index b834f97a..7d18f4ee 100644
--- a/src-migrate/modules/register/components/Form.tsx
+++ b/src-migrate/modules/register/components/Form.tsx
@@ -9,7 +9,12 @@ import { useRouter } from "next/router";
 import { UseToastOptions, useToast } from "@chakra-ui/react";
 import Link from "next/link";
 
-const Form = () => {
+interface FormProps {
+  type: string;
+  required: boolean;
+}
+
+const Form: React.FC<FormProps> = ({ type, required }) => {
   const {
     form,
     isCheckedTNC,
@@ -75,25 +80,9 @@ const Form = () => {
 
   return (
     <form className="mt-6 grid grid-cols-1 gap-y-4" onSubmit={handleSubmit}>
-      <div>
-        <label htmlFor="company">
-          Nama Perusahaan <span className='text-gray_r-11'>(opsional)</span>
-        </label>
-
-        <input
-          type="text"
-          name="company"
-          id="company"
-          className="form-input mt-3"
-          placeholder="cth: INDOTEKNIK DOTCOM GEMILANG"
-          autoCapitalize="true"
-          value={form.company}
-          onChange={handleInputChange}
-        />
-      </div>
 
       <div>
-        <label htmlFor='name'>Nama Lengkap</label>
+        <label htmlFor='name' className="text-black font-bold">Nama Lengkap</label>
 
         <input
           type='text'
@@ -110,24 +99,7 @@ const Form = () => {
       </div>
 
       <div>
-        <label htmlFor='phone'>No Handphone</label>
-
-        <input
-          type='tel'
-          id='phone'
-          name='phone'
-          className='form-input mt-3'
-          placeholder='08xxxxxxxx'
-          value={form.phone}
-          onChange={handleInputChange}
-          aria-invalid={!!errors.phone}
-        />
-
-        {!!errors.phone && <span className="form-msg-danger">{errors.phone}</span>}
-      </div>
-
-      <div>
-        <label htmlFor='email'>Alamat Email</label>
+        <label htmlFor='email' className="text-black font-bold">Alamat Email</label>
 
         <input
           type='text'
@@ -143,9 +115,9 @@ const Form = () => {
 
         {!!errors.email && <span className="form-msg-danger">{errors.email}</span>}
       </div>
-
+      
       <div>
-        <label htmlFor='password'>Kata Sandi</label>
+        <label htmlFor='password' className="text-black font-bold">Kata Sandi</label>
         <input
           type='password'
           name='password'
@@ -161,17 +133,40 @@ const Form = () => {
         {!!errors.password && <span className="form-msg-danger">{errors.password}</span>}
       </div>
 
-      <FormCaptcha />
+      <div>
+        <label htmlFor='phone' className="text-black font-bold">No Handphone</label>
+
+        <input
+          type='tel'
+          id='phone'
+          name='phone'
+          className='form-input mt-3'
+          placeholder='08xxxxxxxx'
+          value={form.phone}
+          onChange={handleInputChange}
+          aria-invalid={!!errors.phone}
+        />
+
+        {!!errors.phone && <span className="form-msg-danger">{errors.phone}</span>}
+      </div>
+
+      {type==='individu' && (
+        <>
+          <FormCaptcha />
+    
+          <TermCondition />
+          <button
+            type="submit"
+            className="btn-yellow w-full mt-2"
+            disabled={!isFormValid || !isCheckedTNC || mutation.isLoading || !isValidCaptcha}
+          >
+            {mutation.isLoading ? 'Loading...' : 'Daftar'}
+          </button>
+        </>
+
+      )}
 
-      <TermCondition />
 
-      <button
-        type="submit"
-        className="btn-yellow w-full mt-2"
-        disabled={!isFormValid || !isCheckedTNC || mutation.isLoading || !isValidCaptcha}
-      >
-        {mutation.isLoading ? 'Loading...' : 'Daftar'}
-      </button>
     </form>
   )
 }
-- 
cgit v1.2.3


From 0427b70917d7623d5de1969b99e9c198c38ccca7 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 20 Aug 2024 15:53:01 +0700
Subject: <iman< update new register

---
 src-migrate/modules/register/components/Form.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

diff --git a/src-migrate/modules/register/components/Form.tsx b/src-migrate/modules/register/components/Form.tsx
index 7d18f4ee..78566fae 100644
--- a/src-migrate/modules/register/components/Form.tsx
+++ b/src-migrate/modules/register/components/Form.tsx
@@ -152,7 +152,7 @@ const Form: React.FC<FormProps> = ({ type, required }) => {
 
       {type==='individu' && (
         <>
-          <FormCaptcha />
+          {/* <FormCaptcha /> */}
     
           <TermCondition />
           <button
-- 
cgit v1.2.3


From 6623dba2f6cd4a4ca7b25f7086991afef092cd26 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 22 Aug 2024 15:48:00 +0700
Subject: <iman> update new register view

---
 src-migrate/modules/register/components/Form.tsx | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

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

diff --git a/src-migrate/modules/register/components/Form.tsx b/src-migrate/modules/register/components/Form.tsx
index 78566fae..ba28b32f 100644
--- a/src-migrate/modules/register/components/Form.tsx
+++ b/src-migrate/modules/register/components/Form.tsx
@@ -12,9 +12,10 @@ import Link from "next/link";
 interface FormProps {
   type: string;
   required: boolean;
+  isPKP: boolean;
 }
 
-const Form: React.FC<FormProps> = ({ type, required }) => {
+const Form: React.FC<FormProps> = ({ type, required, isPKP }) => {
   const {
     form,
     isCheckedTNC,
@@ -25,6 +26,7 @@ const Form: React.FC<FormProps> = ({ type, required }) => {
   } = useRegisterStore()
 
   const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors])
+  console.log("errors",errors)
 
   const router = useRouter()
   const toast = useToast()
@@ -33,6 +35,17 @@ const Form: React.FC<FormProps> = ({ type, required }) => {
     const { name, value } = event.target;
     updateForm(name, value)
     validate()
+    if(isPKP){
+      updateForm('nama_wajib_pajak','')
+      updateForm('sppkp_document','')
+      updateForm('npwp_document','')
+      updateForm('industry','')
+      updateForm('badanUsaha','')
+      updateForm('email_partner','')
+      updateForm('business_name','')
+      updateForm('companyType','')
+      updateForm('npwp','')
+    }
   }
 
   const mutation = useMutation({
@@ -77,6 +90,7 @@ const Form: React.FC<FormProps> = ({ type, required }) => {
         break
     }
   }
+  console.log(!isFormValid,!isCheckedTNC,mutation.isLoading,!isValidCaptcha)
 
   return (
     <form className="mt-6 grid grid-cols-1 gap-y-4" onSubmit={handleSubmit}>
@@ -152,7 +166,7 @@ const Form: React.FC<FormProps> = ({ type, required }) => {
 
       {type==='individu' && (
         <>
-          {/* <FormCaptcha /> */}
+          <FormCaptcha />
     
           <TermCondition />
           <button
-- 
cgit v1.2.3


From fb346e50e06ed68508662ca3d004db2c2cc117eb Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 22 Aug 2024 16:48:03 +0700
Subject: <iman> update new register

---
 src-migrate/modules/register/components/Form.tsx | 26 ++++++++++++------------
 1 file changed, 13 insertions(+), 13 deletions(-)

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

diff --git a/src-migrate/modules/register/components/Form.tsx b/src-migrate/modules/register/components/Form.tsx
index ba28b32f..76601866 100644
--- a/src-migrate/modules/register/components/Form.tsx
+++ b/src-migrate/modules/register/components/Form.tsx
@@ -12,10 +12,11 @@ import Link from "next/link";
 interface FormProps {
   type: string;
   required: boolean;
-  isPKP: boolean;
+  isBisnisRegist: boolean;
 }
 
-const Form: React.FC<FormProps> = ({ type, required, isPKP }) => {
+const Form: React.FC<FormProps> = ({ type, required, isBisnisRegist=false }) => {
+  console.log("isBisnisRegist",isBisnisRegist)
   const {
     form,
     isCheckedTNC,
@@ -34,18 +35,17 @@ const Form: React.FC<FormProps> = ({ type, required, isPKP }) => {
   const handleInputChange = (event: ChangeEvent<HTMLInputElement>) => {
     const { name, value } = event.target;
     updateForm(name, value)
+    // if(!isBisnisRegist){
+      updateForm('business_name','Iman')
+      updateForm('companyType','iman')
+      updateForm('email_partner','it@fixcomart.co.id')
+      updateForm('industry','1')
+      updateForm('nama_wajib_pajak','Iman')
+      updateForm('npwp','958666666688888')
+      updateForm('npwp_document','adsdad.pdf')
+      updateForm('sppkp_document','fdddwedw.pdf')
+    // }
     validate()
-    if(isPKP){
-      updateForm('nama_wajib_pajak','')
-      updateForm('sppkp_document','')
-      updateForm('npwp_document','')
-      updateForm('industry','')
-      updateForm('badanUsaha','')
-      updateForm('email_partner','')
-      updateForm('business_name','')
-      updateForm('companyType','')
-      updateForm('npwp','')
-    }
   }
 
   const mutation = useMutation({
-- 
cgit v1.2.3


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

---
 src-migrate/modules/register/components/Form.tsx | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

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

diff --git a/src-migrate/modules/register/components/Form.tsx b/src-migrate/modules/register/components/Form.tsx
index 76601866..c4789e9a 100644
--- a/src-migrate/modules/register/components/Form.tsx
+++ b/src-migrate/modules/register/components/Form.tsx
@@ -36,10 +36,13 @@ const Form: React.FC<FormProps> = ({ type, required, isBisnisRegist=false }) =>
     const { name, value } = event.target;
     updateForm(name, value)
     // if(!isBisnisRegist){
+    
+      updateForm('type_acc',`individu`)
+      updateForm('is_pkp','false')
       updateForm('business_name','Iman')
-      updateForm('companyType','iman')
+      updateForm('company_type_id','0')
       updateForm('email_partner','it@fixcomart.co.id')
-      updateForm('industry','1')
+      updateForm('industry_id','0')
       updateForm('nama_wajib_pajak','Iman')
       updateForm('npwp','958666666688888')
       updateForm('npwp_document','adsdad.pdf')
-- 
cgit v1.2.3


From f0cde08a3fda95b1738a765358022241aea404bf Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 26 Aug 2024 10:28:15 +0700
Subject: <iman> update logic new register validation

---
 src-migrate/modules/register/components/Form.tsx | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

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

diff --git a/src-migrate/modules/register/components/Form.tsx b/src-migrate/modules/register/components/Form.tsx
index c4789e9a..5e5e0a11 100644
--- a/src-migrate/modules/register/components/Form.tsx
+++ b/src-migrate/modules/register/components/Form.tsx
@@ -37,16 +37,16 @@ const Form: React.FC<FormProps> = ({ type, required, isBisnisRegist=false }) =>
     updateForm(name, value)
     // if(!isBisnisRegist){
     
-      updateForm('type_acc',`individu`)
-      updateForm('is_pkp','false')
-      updateForm('business_name','Iman')
-      updateForm('company_type_id','0')
-      updateForm('email_partner','it@fixcomart.co.id')
-      updateForm('industry_id','0')
-      updateForm('nama_wajib_pajak','Iman')
-      updateForm('npwp','958666666688888')
-      updateForm('npwp_document','adsdad.pdf')
-      updateForm('sppkp_document','fdddwedw.pdf')
+      // updateForm('type_acc',`individu`)
+      // updateForm('is_pkp','false')
+      // updateForm('business_name','Iman')
+      // updateForm('company_type_id','0')
+      // updateForm('email_partner','it@fixcomart.co.id')
+      // updateForm('industry_id','0')
+      // updateForm('nama_wajib_pajak','Iman')
+      // updateForm('npwp','958666666688888')
+      // updateForm('npwp_document','adsdad.pdf')
+      // updateForm('sppkp_document','fdddwedw.pdf')
     // }
     validate()
   }
-- 
cgit v1.2.3


From 54b6b618effc8416027ed884be1d6d37257c26c4 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 26 Aug 2024 11:59:57 +0700
Subject: <iman> update fungsion component

---
 src-migrate/modules/register/components/Form.tsx | 33 ++----------------------
 1 file changed, 2 insertions(+), 31 deletions(-)

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

diff --git a/src-migrate/modules/register/components/Form.tsx b/src-migrate/modules/register/components/Form.tsx
index 5e5e0a11..29c21f62 100644
--- a/src-migrate/modules/register/components/Form.tsx
+++ b/src-migrate/modules/register/components/Form.tsx
@@ -16,7 +16,6 @@ interface FormProps {
 }
 
 const Form: React.FC<FormProps> = ({ type, required, isBisnisRegist=false }) => {
-  console.log("isBisnisRegist",isBisnisRegist)
   const {
     form,
     isCheckedTNC,
@@ -27,7 +26,6 @@ const Form: React.FC<FormProps> = ({ type, required, isBisnisRegist=false }) =>
   } = useRegisterStore()
 
   const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors])
-  console.log("errors",errors)
 
   const router = useRouter()
   const toast = useToast()
@@ -35,19 +33,6 @@ const Form: React.FC<FormProps> = ({ type, required, isBisnisRegist=false }) =>
   const handleInputChange = (event: ChangeEvent<HTMLInputElement>) => {
     const { name, value } = event.target;
     updateForm(name, value)
-    // if(!isBisnisRegist){
-    
-      // updateForm('type_acc',`individu`)
-      // updateForm('is_pkp','false')
-      // updateForm('business_name','Iman')
-      // updateForm('company_type_id','0')
-      // updateForm('email_partner','it@fixcomart.co.id')
-      // updateForm('industry_id','0')
-      // updateForm('nama_wajib_pajak','Iman')
-      // updateForm('npwp','958666666688888')
-      // updateForm('npwp_document','adsdad.pdf')
-      // updateForm('sppkp_document','fdddwedw.pdf')
-    // }
     validate()
   }
 
@@ -93,7 +78,7 @@ const Form: React.FC<FormProps> = ({ type, required, isBisnisRegist=false }) =>
         break
     }
   }
-  console.log(!isFormValid,!isCheckedTNC,mutation.isLoading,!isValidCaptcha)
+  
 
   return (
     <form className="mt-6 grid grid-cols-1 gap-y-4" onSubmit={handleSubmit}>
@@ -167,21 +152,7 @@ const Form: React.FC<FormProps> = ({ type, required, isBisnisRegist=false }) =>
         {!!errors.phone && <span className="form-msg-danger">{errors.phone}</span>}
       </div>
 
-      {type==='individu' && (
-        <>
-          <FormCaptcha />
-    
-          <TermCondition />
-          <button
-            type="submit"
-            className="btn-yellow w-full mt-2"
-            disabled={!isFormValid || !isCheckedTNC || mutation.isLoading || !isValidCaptcha}
-          >
-            {mutation.isLoading ? 'Loading...' : 'Daftar'}
-          </button>
-        </>
-
-      )}
+     
 
 
     </form>
-- 
cgit v1.2.3


From 6ff5efdb4b7eec25f991f5bfcc02b4a3f883981b Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 11 Sep 2024 10:04:31 +0700
Subject: <iman> update error handling hanya muncul saat button daftar di click

---
 src-migrate/modules/register/components/Form.tsx | 152 +++++++++++++----------
 1 file changed, 85 insertions(+), 67 deletions(-)

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

diff --git a/src-migrate/modules/register/components/Form.tsx b/src-migrate/modules/register/components/Form.tsx
index 29c21f62..118d9d69 100644
--- a/src-migrate/modules/register/components/Form.tsx
+++ b/src-migrate/modules/register/components/Form.tsx
@@ -1,90 +1,98 @@
-import { ChangeEvent, useMemo } from "react";
-import { useMutation } from "react-query";
-import { useRegisterStore } from "../stores/useRegisterStore";
-import { RegisterProps } from "~/types/auth";
-import { registerUser } from "~/services/auth";
-import TermCondition from "./TermCondition";
-import FormCaptcha from "./FormCaptcha";
-import { useRouter } from "next/router";
-import { UseToastOptions, useToast } from "@chakra-ui/react";
-import Link from "next/link";
+import { ChangeEvent, useMemo } from 'react';
+import { useMutation } from 'react-query';
+import { useRegisterStore } from '../stores/useRegisterStore';
+import { RegisterProps } from '~/types/auth';
+import { registerUser } from '~/services/auth';
+import TermCondition from './TermCondition';
+import FormCaptcha from './FormCaptcha';
+import { useRouter } from 'next/router';
+import { UseToastOptions, useToast } from '@chakra-ui/react';
+import Link from 'next/link';
 
 interface FormProps {
   type: string;
   required: boolean;
   isBisnisRegist: boolean;
+  chekValid: boolean;
 }
 
-const Form: React.FC<FormProps> = ({ type, required, isBisnisRegist=false }) => {
-  const {
-    form,
-    isCheckedTNC,
-    isValidCaptcha,
-    errors,
-    updateForm,
-    validate,
-  } = useRegisterStore()
+const Form: React.FC<FormProps> = ({
+  type,
+  required,
+  isBisnisRegist = false,
+  chekValid = false,
+}) => {
+  const { form, isCheckedTNC, isValidCaptcha, errors, updateForm, validate } =
+    useRegisterStore();
 
-  const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors])
+  const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]);
 
-  const router = useRouter()
-  const toast = useToast()
+  const router = useRouter();
+  const toast = useToast();
 
   const handleInputChange = (event: ChangeEvent<HTMLInputElement>) => {
     const { name, value } = event.target;
-    updateForm(name, value)
-    validate()
-  }
+    updateForm(name, value);
+    validate();
+  };
 
   const mutation = useMutation({
-    mutationFn: (data: RegisterProps) => registerUser(data)
-  })
+    mutationFn: (data: RegisterProps) => registerUser(data),
+  });
 
   const handleSubmit = async (e: ChangeEvent<HTMLFormElement>) => {
-    e.preventDefault()
+    e.preventDefault();
 
-    const response = await mutation.mutateAsync(form)
+    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}`)
+        redirect: (router.query?.next || '/') as string,
+      });
+      router.push(`${router.route}?${urlParams}`);
     }
 
     const toastProps: UseToastOptions = {
       duration: 5000,
-      isClosable: true
-    }
+      isClosable: true,
+      position: 'top',
+    };
 
     switch (response?.reason) {
       case 'EMAIL_USED':
         toast({
           ...toastProps,
           title: 'Email sudah digunakan',
-          status: 'warning'
-        })
+          status: 'warning',
+        });
         break;
       case 'NOT_ACTIVE':
-        const activationUrl = `${router.route}?activation=email`
+        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
+          description: (
+            <>
+              Akun sudah terdaftar namun belum aktif.{' '}
+              <Link href={activationUrl} className='underline'>
+                Klik untuk aktivasi akun
+              </Link>
+            </>
+          ),
+          status: 'warning',
+        });
+        break;
     }
-  }
-  
+  };
 
   return (
-    <form className="mt-6 grid grid-cols-1 gap-y-4" onSubmit={handleSubmit}>
-
+    <form className='mt-6 grid grid-cols-1 gap-y-4' onSubmit={handleSubmit}>
       <div>
-        <label htmlFor='name' className="text-black font-bold">Nama Lengkap</label>
+        <label htmlFor='name' className='text-black font-bold'>
+          Nama Lengkap
+        </label>
 
         <input
           type='text'
@@ -94,14 +102,18 @@ const Form: React.FC<FormProps> = ({ type, required, isBisnisRegist=false }) =>
           placeholder='Masukan nama lengkap anda'
           value={form.name}
           onChange={handleInputChange}
-          aria-invalid={!!errors.name}
+          aria-invalid={chekValid && !!errors.name}
         />
 
-        {!!errors.name && <span className="form-msg-danger">{errors.name}</span>}
+        {chekValid && !!errors.name && (
+          <span className='form-msg-danger'>{errors.name}</span>
+        )}
       </div>
 
       <div>
-        <label htmlFor='email' className="text-black font-bold">Alamat Email</label>
+        <label htmlFor='email' className='text-black font-bold'>
+          Alamat Email
+        </label>
 
         <input
           type='text'
@@ -111,15 +123,19 @@ const Form: React.FC<FormProps> = ({ type, required, isBisnisRegist=false }) =>
           placeholder='Masukan alamat email anda'
           value={form.email}
           onChange={handleInputChange}
-          autoComplete="username"
-          aria-invalid={!!errors.email}
+          autoComplete='username'
+          aria-invalid={chekValid && !!errors.email}
         />
 
-        {!!errors.email && <span className="form-msg-danger">{errors.email}</span>}
+        {chekValid && !!errors.email && (
+          <span className='form-msg-danger'>{errors.email}</span>
+        )}
       </div>
-      
+
       <div>
-        <label htmlFor='password' className="text-black font-bold">Kata Sandi</label>
+        <label htmlFor='password' className='text-black font-bold'>
+          Kata Sandi
+        </label>
         <input
           type='password'
           name='password'
@@ -128,15 +144,19 @@ const Form: React.FC<FormProps> = ({ type, required, isBisnisRegist=false }) =>
           placeholder='••••••••••••'
           value={form.password}
           onChange={handleInputChange}
-          autoComplete="current-password"
-          aria-invalid={!!errors.password}
+          autoComplete='current-password'
+          aria-invalid={chekValid && !!errors.password}
         />
 
-        {!!errors.password && <span className="form-msg-danger">{errors.password}</span>}
+        {chekValid && !!errors.password && (
+          <span className='form-msg-danger'>{errors.password}</span>
+        )}
       </div>
 
       <div>
-        <label htmlFor='phone' className="text-black font-bold">No Handphone</label>
+        <label htmlFor='phone' className='text-black font-bold'>
+          No Handphone
+        </label>
 
         <input
           type='tel'
@@ -146,17 +166,15 @@ const Form: React.FC<FormProps> = ({ type, required, isBisnisRegist=false }) =>
           placeholder='08xxxxxxxx'
           value={form.phone}
           onChange={handleInputChange}
-          aria-invalid={!!errors.phone}
+          aria-invalid={chekValid && !!errors.phone}
         />
 
-        {!!errors.phone && <span className="form-msg-danger">{errors.phone}</span>}
+        {chekValid && !!errors.phone && (
+          <span className='form-msg-danger'>{errors.phone}</span>
+        )}
       </div>
-
-     
-
-
     </form>
-  )
-}
+  );
+};
 
-export default Form
\ No newline at end of file
+export default Form;
-- 
cgit v1.2.3


From aaf907c834343970e1d30b3ef49c13ed5f9d34ed Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 17 Sep 2024 09:01:04 +0700
Subject: <iman> add focus error when button submit click

---
 src-migrate/modules/register/components/Form.tsx | 43 ++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)

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

diff --git a/src-migrate/modules/register/components/Form.tsx b/src-migrate/modules/register/components/Form.tsx
index 118d9d69..b04e763c 100644
--- a/src-migrate/modules/register/components/Form.tsx
+++ b/src-migrate/modules/register/components/Form.tsx
@@ -1,4 +1,4 @@
-import { ChangeEvent, useMemo } from 'react';
+import { ChangeEvent, useMemo, useEffect, useRef, useState } from 'react';
 import { useMutation } from 'react-query';
 import { useRegisterStore } from '../stores/useRegisterStore';
 import { RegisterProps } from '~/types/auth';
@@ -14,13 +14,15 @@ interface FormProps {
   required: boolean;
   isBisnisRegist: boolean;
   chekValid: boolean;
+  buttonSubmitClick: boolean;
 }
 
 const Form: React.FC<FormProps> = ({
   type,
   required,
   isBisnisRegist = false,
-  chekValid = false,
+  chekValid,
+  buttonSubmitClick,
 }) => {
   const { form, isCheckedTNC, isValidCaptcha, errors, updateForm, validate } =
     useRegisterStore();
@@ -30,6 +32,11 @@ const Form: React.FC<FormProps> = ({
   const router = useRouter();
   const toast = useToast();
 
+  const emailRef = useRef<HTMLInputElement>(null);
+  const nameRef = useRef<HTMLInputElement>(null);
+  const passwordRef = useRef<HTMLInputElement>(null);
+  const teleponRef = useRef<HTMLDivElement>(null);
+
   const handleInputChange = (event: ChangeEvent<HTMLInputElement>) => {
     const { name, value } = event.target;
     updateForm(name, value);
@@ -40,6 +47,34 @@ const Form: React.FC<FormProps> = ({
     mutationFn: (data: RegisterProps) => registerUser(data),
   });
 
+  useEffect(() => {
+    const loadIndustries = async () => {
+      const response = await mutation.mutateAsync(form);
+      if (!response?.register) {
+        // Logic to focus on first invalid input
+        if (errors.email_partner && emailRef.current) {
+          emailRef.current.focus();
+          return;
+        }
+        if (errors.name && nameRef.current) {
+          nameRef.current.focus();
+          return;
+        }
+
+        if (errors.password && passwordRef.current) {
+          passwordRef.current.focus();
+          return;
+        }
+
+        if (errors.phone && teleponRef.current) {
+          teleponRef.current.scrollIntoView();
+          return;
+        }
+      }
+    };
+    loadIndustries();
+  }, [buttonSubmitClick]);
+
   const handleSubmit = async (e: ChangeEvent<HTMLFormElement>) => {
     e.preventDefault();
 
@@ -101,6 +136,7 @@ const Form: React.FC<FormProps> = ({
           className='form-input mt-3'
           placeholder='Masukan nama lengkap anda'
           value={form.name}
+          ref={nameRef}
           onChange={handleInputChange}
           aria-invalid={chekValid && !!errors.name}
         />
@@ -122,6 +158,7 @@ const Form: React.FC<FormProps> = ({
           className='form-input mt-3'
           placeholder='Masukan alamat email anda'
           value={form.email}
+          ref={emailRef}
           onChange={handleInputChange}
           autoComplete='username'
           aria-invalid={chekValid && !!errors.email}
@@ -143,6 +180,7 @@ const Form: React.FC<FormProps> = ({
           className='form-input mt-3'
           placeholder='••••••••••••'
           value={form.password}
+          ref={passwordRef}
           onChange={handleInputChange}
           autoComplete='current-password'
           aria-invalid={chekValid && !!errors.password}
@@ -163,6 +201,7 @@ const Form: React.FC<FormProps> = ({
           id='phone'
           name='phone'
           className='form-input mt-3'
+          ref={passwordRef}
           placeholder='08xxxxxxxx'
           value={form.phone}
           onChange={handleInputChange}
-- 
cgit v1.2.3


From 810c5da6e26fdfc4f29df75dca13c0fdb787f34a Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 18 Sep 2024 09:29:41 +0700
Subject: <iman> update auto scrool to when error

---
 src-migrate/modules/register/components/Form.tsx | 32 +++++++++++++-----------
 1 file changed, 18 insertions(+), 14 deletions(-)

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

diff --git a/src-migrate/modules/register/components/Form.tsx b/src-migrate/modules/register/components/Form.tsx
index b04e763c..55d542f2 100644
--- a/src-migrate/modules/register/components/Form.tsx
+++ b/src-migrate/modules/register/components/Form.tsx
@@ -26,7 +26,7 @@ const Form: React.FC<FormProps> = ({
 }) => {
   const { form, isCheckedTNC, isValidCaptcha, errors, updateForm, validate } =
     useRegisterStore();
-
+  console.log('buttonSubmitClick', buttonSubmitClick);
   const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]);
 
   const router = useRouter();
@@ -35,7 +35,7 @@ const Form: React.FC<FormProps> = ({
   const emailRef = useRef<HTMLInputElement>(null);
   const nameRef = useRef<HTMLInputElement>(null);
   const passwordRef = useRef<HTMLInputElement>(null);
-  const teleponRef = useRef<HTMLDivElement>(null);
+  const phoneRef = useRef<HTMLInputElement>(null);
 
   const handleInputChange = (event: ChangeEvent<HTMLInputElement>) => {
     const { name, value } = event.target;
@@ -51,29 +51,33 @@ const Form: React.FC<FormProps> = ({
     const loadIndustries = async () => {
       const response = await mutation.mutateAsync(form);
       if (!response?.register) {
-        // Logic to focus on first invalid input
+        const options: ScrollIntoViewOptions = {
+          behavior: 'smooth',
+          block: 'center',
+        };
+
         if (errors.email_partner && emailRef.current) {
-          emailRef.current.focus();
+          emailRef.current.scrollIntoView(options);
           return;
         }
         if (errors.name && nameRef.current) {
-          nameRef.current.focus();
+          nameRef.current.scrollIntoView(options);
           return;
         }
 
         if (errors.password && passwordRef.current) {
-          passwordRef.current.focus();
+          passwordRef.current.scrollIntoView(options);
           return;
         }
 
-        if (errors.phone && teleponRef.current) {
-          teleponRef.current.scrollIntoView();
+        if (errors.phone && phoneRef.current) {
+          phoneRef.current.scrollIntoView(options);
           return;
         }
       }
     };
     loadIndustries();
-  }, [buttonSubmitClick]);
+  }, [buttonSubmitClick, chekValid]);
 
   const handleSubmit = async (e: ChangeEvent<HTMLFormElement>) => {
     e.preventDefault();
@@ -133,7 +137,7 @@ const Form: React.FC<FormProps> = ({
           type='text'
           id='name'
           name='name'
-          className='form-input mt-3'
+          className='form-input mt-3 transition-all duration-700'
           placeholder='Masukan nama lengkap anda'
           value={form.name}
           ref={nameRef}
@@ -155,7 +159,7 @@ const Form: React.FC<FormProps> = ({
           type='text'
           id='email'
           name='email'
-          className='form-input mt-3'
+          className='form-input mt-3 transition-all duration-500'
           placeholder='Masukan alamat email anda'
           value={form.email}
           ref={emailRef}
@@ -177,7 +181,7 @@ const Form: React.FC<FormProps> = ({
           type='password'
           name='password'
           id='password'
-          className='form-input mt-3'
+          className='form-input mt-3 transition-all duration-500'
           placeholder='••••••••••••'
           value={form.password}
           ref={passwordRef}
@@ -200,10 +204,10 @@ const Form: React.FC<FormProps> = ({
           type='tel'
           id='phone'
           name='phone'
-          className='form-input mt-3'
-          ref={passwordRef}
+          className='form-input mt-3 transition-all duration-500'
           placeholder='08xxxxxxxx'
           value={form.phone}
+          ref={phoneRef}
           onChange={handleInputChange}
           aria-invalid={chekValid && !!errors.phone}
         />
-- 
cgit v1.2.3


From 4aface3ba2fa7c74a152ac0fe03b9e32e3ef68e1 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 18 Sep 2024 10:06:14 +0700
Subject: <iman> update bug ga bisa pilih alamat

---
 src-migrate/modules/register/components/Form.tsx | 1 -
 1 file changed, 1 deletion(-)

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

diff --git a/src-migrate/modules/register/components/Form.tsx b/src-migrate/modules/register/components/Form.tsx
index 55d542f2..cd0b4343 100644
--- a/src-migrate/modules/register/components/Form.tsx
+++ b/src-migrate/modules/register/components/Form.tsx
@@ -26,7 +26,6 @@ const Form: React.FC<FormProps> = ({
 }) => {
   const { form, isCheckedTNC, isValidCaptcha, errors, updateForm, validate } =
     useRegisterStore();
-  console.log('buttonSubmitClick', buttonSubmitClick);
   const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]);
 
   const router = useRouter();
-- 
cgit v1.2.3


From c651d654c2c87d26aab184025b7d0e4d8e74e65f Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 19 Sep 2024 10:11:47 +0700
Subject: <iman> fix otp send 3 times

---
 src-migrate/modules/register/components/Form.tsx | 57 +-----------------------
 1 file changed, 2 insertions(+), 55 deletions(-)

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

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<FormProps> = ({
     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<FormProps> = ({
     loadIndustries();
   }, [buttonSubmitClick, chekValid]);
 
-  const handleSubmit = async (e: ChangeEvent<HTMLFormElement>) => {
-    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.{' '}
-              <Link href={activationUrl} className='underline'>
-                Klik untuk aktivasi akun
-              </Link>
-            </>
-          ),
-          status: 'warning',
-        });
-        break;
-    }
-  };
-
   return (
-    <form className='mt-6 grid grid-cols-1 gap-y-4' onSubmit={handleSubmit}>
+    <form className='mt-6 grid grid-cols-1 gap-y-4'>
       <div>
         <label htmlFor='name' className='text-black font-bold'>
           Nama Lengkap
-- 
cgit v1.2.3

