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/Referensi.jsx | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

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

diff --git a/src/lib/pengajuan-tempo/component/Referensi.jsx b/src/lib/pengajuan-tempo/component/Referensi.jsx
index 17ac6cb0..b8c2f7eb 100644
--- a/src/lib/pengajuan-tempo/component/Referensi.jsx
+++ b/src/lib/pengajuan-tempo/component/Referensi.jsx
@@ -1,6 +1,9 @@
 import React, { useState, useEffect, useMemo, useRef } from 'react';
 import { useForm } from 'react-hook-form';
-import { usePengajuanTempoStoreSupplier } from '../../../../src-migrate/modules/register/stores/usePengajuanTempoStore';
+import {
+  usePengajuanTempoStoreSupplier,
+  usePengajuanTempoStore,
+} from '../../../../src-migrate/modules/register/stores/usePengajuanTempoStore';
 import * as Yup from 'yup';
 import { yupResolver } from '@hookform/resolvers/yup';
 import { PlusCircleIcon } from '@heroicons/react/24/outline';
@@ -8,7 +11,7 @@ import useDevice from '@/core/hooks/useDevice';
 import { Trash2Icon } from 'lucide-react';
 import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline';
 const initialData = [];
-const Referensi = ({ chekValid, buttonSubmitClick }) => {
+const Referensi = ({ chekValid, buttonSubmitClick, data }) => {
   const { isDesktop, isMobile } = useDevice();
   const [openIndexes, setOpenIndexes] = useState([]);
 
@@ -25,6 +28,7 @@ const Referensi = ({ chekValid, buttonSubmitClick }) => {
   });
   const { formSupplier, updateFormSupplier, updateHasSave } =
     usePengajuanTempoStoreSupplier();
+  const { form } = usePengajuanTempoStore();
   const [formData, setFormData] = useState([
     {
       supplier: '',
@@ -153,10 +157,13 @@ const Referensi = ({ chekValid, buttonSubmitClick }) => {
     return item;
   };
   useEffect(() => {
-    const cachedData = getFromLocalStorage('Referensi');
-    if (cachedData) {
-      setSupplierData(cachedData);
-      updateFormSupplier(cachedData);
+    console.log('supplierData', supplierData);
+    console.log('form supplier', formSupplier);
+    console.log('data', data);
+    // const cachedData = getFromLocalStorage('Referensi');
+    if (data) {
+      setSupplierData(data);
+      updateFormSupplier(data);
     }
   }, [buttonSubmitClick]);
 
@@ -169,6 +176,7 @@ const Referensi = ({ chekValid, buttonSubmitClick }) => {
       prev.includes(index) ? prev.filter((i) => i !== index) : [...prev, index]
     );
   };
+
   return (
     <>
       {isDesktop && (
-- 
cgit v1.2.3

