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

---
 .../register/components/RegistrasiBisnis.tsx        | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

(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 6ace27f9..b8ea5fff 100644
--- a/src-migrate/modules/register/components/RegistrasiBisnis.tsx
+++ b/src-migrate/modules/register/components/RegistrasiBisnis.tsx
@@ -29,13 +29,11 @@ const RegistrasiBisnis = () => {
   const [selectedValueBisnis, setSelectedValueBisnis] = useState('false');
    const {
     form,
-    formBisnis,
     isCheckedTNC,
     isValidCaptcha,
     errors,
-    updateFormBisnis,
-    validateFormBisnis,
     validate,
+    updateForm
   } = useRegisterStore()
   const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors])
   const toast = useToast()
@@ -45,18 +43,18 @@ const RegistrasiBisnis = () => {
 
   useEffect(() => {
     if (selectedValue === "PKP") {
-      updateFormBisnis("is_pkp", 'true');
-      validateFormBisnis();
+      updateForm("is_pkp", 'true');
+      validate();
     } else {
-      updateFormBisnis("is_pkp", 'false');
-      validateFormBisnis();
+      updateForm("is_pkp", 'false');
+      validate();
     }
   }, [selectedValue,]);
 
   const   handleChange = (value: string) => {
     setSelectedValue(value);
     if (value === "PKP") {
-      validateFormBisnis();
+      validate();
       setIsIndividuRequired(true);
       setIsPKP(true);
     } else {
@@ -68,9 +66,12 @@ const RegistrasiBisnis = () => {
 
   const handleChangeBisnis = (value: string) => {
     setSelectedValueBisnis(value);
+    console.log('value',value)
     if (value === "true") {
+      updateForm('is_terdaftar','true')
       setIsTerdaftar(true);
     } else {
+      updateForm('is_terdaftar','false')
       setIsTerdaftar(false);
     }
   };
@@ -85,8 +86,8 @@ const RegistrasiBisnis = () => {
 
   const handleSubmit = async () => {
     console.log("form",form)
-    console.log("form Bisnis",formBisnis)
-    const response = await mutation.mutateAsync(formBisnis)
+    console.log("form Bisnis",form)
+    const response = await mutation.mutateAsync(form)
 
     console.log("response",response)
 
-- 
cgit v1.2.3

