From 661d742193b62aeb3d2a2350433bdd3714667625 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Fri, 18 Oct 2024 10:39:40 +0700
Subject: <iman> add kontak perusahaan

---
 .../pengajuan-tempo/component/PengajuanTempo.jsx   | 32 ++++++++++++++++++----
 1 file changed, 27 insertions(+), 5 deletions(-)

(limited to 'src/lib/pengajuan-tempo/component/PengajuanTempo.jsx')

diff --git a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
index c15189d1..b2e9832e 100644
--- a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
+++ b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
@@ -4,14 +4,22 @@ import Stepper from './Stepper';
 import InformasiPerusahaan from './informasiPerusahaan';
 import KontakPerusahaan from './KontakPerusahaan';
 import { Controller, useForm } from 'react-hook-form';
-import { usePengajuanTempoStore } from '../../../../src-migrate/modules/register/stores/usePengajuanTempoStore';
+import {
+  usePengajuanTempoStore,
+  usePengajuanTempoStoreKontakPerson,
+} from '../../../../src-migrate/modules/register/stores/usePengajuanTempoStore';
 import { ChevronRightIcon } from '@heroicons/react/24/outline';
 const PengajuanTempo = () => {
   const [currentStep, setCurrentStep] = React.useState(0);
   const NUMBER_OF_STEPS = 6;
   const { form, errors, validate, updateForm } = usePengajuanTempoStore();
+  const {
+    formKontakPerson,
+    errorsKontakPerson,
+    validateKontakPerson,
+    updateFormKontakPerson,
+  } = usePengajuanTempoStoreKontakPerson();
   const [notValid, setNotValid] = useState(false);
-  const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]);
   const [buttonSubmitClick, setButtonSubmitClick] = useState(false);
   const stepDivs = [
     <KontakPerusahaan
@@ -28,21 +36,35 @@ const PengajuanTempo = () => {
     <div>Dokumen</div>,
     <div>Konfirmasi</div>,
   ];
+  const stepDivsError = [
+    errorsKontakPerson,
+    errors,
+    <div>Kontak Person</div>,
+    <div>Pengiriman</div>,
+    <div>Referensi</div>,
+    <div>Dokumen</div>,
+    <div>Konfirmasi</div>,
+  ];
 
+  const isFormValid = useMemo(
+    () => Object.keys(stepDivsError[currentStep]).length === 0,
+    [stepDivsError[currentStep]]
+  );
   useEffect(() => {
     validate();
+    validateKontakPerson();
   }, []);
-
+  console.log('isFormValid', isFormValid);
   const goToNextStep = () => {
     if (!isFormValid) {
       setNotValid(true);
       setButtonSubmitClick(!buttonSubmitClick);
       console.log('form', form);
-      console.log('error', errors);
+      console.log('error', stepDivsError[currentStep]);
       return;
     } else {
       console.log('form', form);
-      console.log('error', errors);
+      console.log('error', stepDivsError[currentStep]);
       setButtonSubmitClick(!buttonSubmitClick);
       setNotValid(false);
     }
-- 
cgit v1.2.3

