From abcce110895d767a16fb961a65e7c78f9213ca0d Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 24 Oct 2024 17:11:32 +0700
Subject: <iman> update pengajuan tempo

---
 .../pengajuan-tempo/component/PengajuanTempo.jsx   | 54 ++++++++++++++++++----
 1 file changed, 45 insertions(+), 9 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 030583aa..66d5ea1c 100644
--- a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
+++ b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
@@ -7,6 +7,8 @@ import Pengiriman from './Pengiriman';
 import Referensi from './Referensi';
 import Dokumen from './Dokumen';
 import Konfirmasi from './Konfirmasi';
+import useAuth from '@/core/hooks/useAuth';
+import { useRouter } from 'next/router';
 import { Controller, useForm } from 'react-hook-form';
 import {
   usePengajuanTempoStore,
@@ -21,6 +23,8 @@ const PengajuanTempo = () => {
   const NUMBER_OF_STEPS = 6;
   const { form, errors, validate, updateForm } = usePengajuanTempoStore();
   const { control, watch, setValue } = useForm();
+  const auth = useAuth();
+  const router = useRouter();
   const { formDokumen, errorsDokumen, validateDokumen, updateFormDokumen } =
     usePengajuanTempoStoreDokumen();
   const {
@@ -86,6 +90,15 @@ const PengajuanTempo = () => {
     'Konfirmasi',
   ];
 
+  // const stepLabels = [
+  //   `${auth.partnerId}_informasi_perusahaan`,
+  //   `${auth.partnerId}_kontak_person`,
+  //   `${auth.partnerId}_Pengiriman`,
+  //   `${auth.partnerId}_Referensi`,
+  //   `${auth.partnerId}_Dokumen`,
+  //   `${auth.partnerId}_Konfirmasi`,
+  // ];
+
   const isFormValid = useMemo(
     () => Object.keys(stepDivsError[currentStep]).length === 0,
     [stepDivsError[currentStep]]
@@ -135,6 +148,19 @@ const PengajuanTempo = () => {
     }
     setCurrentStep((prev) => (prev === NUMBER_OF_STEPS - 1 ? prev : prev + 1));
   };
+  const handleDaftarTempo = () => {
+    router.push('/pengajuan-tempo/finish?order_id=SO-2023-06480');
+    // if (!isFormValid) {
+    //   setNotValid(true);
+    //   setButtonSubmitClick(!buttonSubmitClick);
+    //   return;
+    // } else {
+    //   saveToLocalStorage(stepLabels[currentStep], stepDivsForm[currentStep]);
+    //   setButtonSubmitClick(!buttonSubmitClick);
+    //   setNotValid(false);
+    // }
+    // setCurrentStep((prev) => (prev === NUMBER_OF_STEPS - 1 ? prev : prev + 1));
+  };
 
   const goToPreviousStep = () => {
     setCurrentStep((prev) => (prev <= 0 ? prev : prev - 1));
@@ -184,21 +210,31 @@ const PengajuanTempo = () => {
           <span className='text-xs opacity-60'>
             *Pastikan data yang anda masukan sudah benar dan sesuai
           </span>
-          <button
+          {/* <button
             onClick={goToPreviousStep}
             className='bg-red-600 border border-red-600 rounded-md text-sm text-white p-2 h-11 mb-1 content-center flex flex-row justify-center items-center'
             disabled={currentStep === 0} // Disable if on the first step
           >
             {<ChevronLeftIcon className='w-5' />}
             Langkah Sebelumnya
-          </button>
-          <button
-            onClick={goToNextStep}
-            disabled={currentStep === NUMBER_OF_STEPS - 1}
-            className='bg-red-600 border border-red-600 rounded-md text-sm text-white p-2 h-11 mb-1 content-center flex flex-row justify-center items-center'
-          >
-            Langkah Selanjutnya {<ChevronRightIcon className='w-5' />}
-          </button>
+          </button> */}
+          {currentStep < 5 && (
+            <button
+              onClick={goToNextStep}
+              disabled={currentStep === NUMBER_OF_STEPS - 1}
+              className='bg-red-600 border border-red-600 rounded-md text-sm text-white p-2 h-11 mb-1 content-center flex flex-row justify-center items-center'
+            >
+              Langkah Selanjutnya {<ChevronRightIcon className='w-5' />}
+            </button>
+          )}
+          {currentStep == 5 && (
+            <button
+              onClick={handleDaftarTempo}
+              className='bg-red-600 border border-red-600 rounded-md text-sm text-white p-2 h-11 mb-1 content-center flex flex-row justify-center items-center'
+            >
+              Daftar Tempo {<ChevronRightIcon className='w-5' />}
+            </button>
+          )}
         </div>
       </div>
     </>
-- 
cgit v1.2.3

