From 494909f40b918e4273d6258a74f12ac42253a4a7 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 25 Nov 2024 17:04:51 +0700
Subject: <iman> pengajuan tempo

---
 src/lib/pengajuan-tempo/component/PengajuanTempo.jsx | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 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 952c4244..ab66f94f 100644
--- a/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
+++ b/src/lib/pengajuan-tempo/component/PengajuanTempo.jsx
@@ -79,6 +79,7 @@ const PengajuanTempo = () => {
       key='referensi'
       chekValid={notValid}
       buttonSubmitClick={buttonSubmitClick}
+      data={bigData?.supplierIds}
     />,
     <Dokumen
       key='dokumen'
@@ -192,7 +193,6 @@ const PengajuanTempo = () => {
   useEffect(() => {
     const cachedData = bigData;
     console.log('data_lama', getFromLocalStorage(stepLabels[currentStep]));
-    console.log('cachedData', cachedData);
 
     if (cachedData) {
       // Ambil kunci-kunci yang relevan berdasarkan currentStep dari stepDivsForm
@@ -201,7 +201,8 @@ const PengajuanTempo = () => {
         : [];
       console.log('formKeys', formKeys);
       if (currentStep === 3) {
-        stepDivsUpdateForm[currentStep](cachedData);
+        console.log('cachedData', cachedData.supplierIds[0]);
+        stepDivsUpdateForm[currentStep](cachedData.supplierIds);
       } else if (currentStep === 4) {
         formKeys.forEach((key) => {
           if (cachedData[key]) {
@@ -230,6 +231,7 @@ const PengajuanTempo = () => {
     validateKontakPerson();
     validatePengiriman();
     validateDokumen();
+    validateSupplier();
     updateHasSave(false);
   }, [currentStep, bigData]);
 
@@ -292,6 +294,7 @@ const PengajuanTempo = () => {
   const handleDaftarTempoDokumen = async () => {
     for (const error of stepDivsError) {
       if (error.length > 0) {
+        console.log('iman_erro', error);
         return;
       }
     }
@@ -337,6 +340,7 @@ const PengajuanTempo = () => {
       durasiTempo: product.durasiTempo,
       creditLimit: product.creditLimit,
     }));
+    console.log('productOrder', productOrder);
     const toastId = toast.loading('Mengirimkan formulir pengajuan tempo...');
     setIsLoading(true);
     try {
@@ -344,6 +348,7 @@ const PengajuanTempo = () => {
         id: idTempo,
         user_id: auth.parentId,
         formSupplier: JSON.stringify(productOrder),
+        section,
       });
       if (address.id) {
         setIdTempo(address.id);
@@ -380,11 +385,6 @@ const PengajuanTempo = () => {
         base64: doc.base64,
       },
     }));
-    if (currentStep == 3) {
-      formData = JSON.stringify(productOrder);
-    } else if (currentStep == 4) {
-      formData = JSON.stringify(formattedDokumen);
-    }
 
     const data2 = {
       user_id: auth.id,
@@ -401,10 +401,10 @@ const PengajuanTempo = () => {
       const address = await createPengajuanTempoApi({
         id: 0,
         user_id: auth.parentId,
-        section: label,
         tempo_request: tempoRequest,
         ...form,
       });
+      console.log('address', address);
       if (address.id) {
         const address2 = await createPengajuanTempoApi({
           id: address.id,
-- 
cgit v1.2.3

