From 654fbb128ab331c3272d6e8733dda1b5b71f4253 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 25 Nov 2024 10:05:02 +0700
Subject: <iman> update pengajuan tempo

---
 src/lib/pengajuan-tempo/component/Referensi.jsx | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 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 5ec64611..17ac6cb0 100644
--- a/src/lib/pengajuan-tempo/component/Referensi.jsx
+++ b/src/lib/pengajuan-tempo/component/Referensi.jsx
@@ -79,6 +79,13 @@ const Referensi = ({ chekValid, buttonSubmitClick }) => {
     updateHasSave(false);
   };
 
+  const handleDeleteSupplier = (index) => {
+    const updatedData = supplierData.filter((_, i) => i !== index);
+    setSupplierData(updatedData);
+    updateFormSupplier(updatedData); // Update store atau state terkait
+    updateHasSave(false); // Indikasi bahwa data telah berubah
+  };
+
   const handleAddNewSupplier = () => {
     if (Object.values(newSupplier).every((val) => val.trim() !== '')) {
       setSupplierData((prevData) => {
@@ -232,7 +239,7 @@ const Referensi = ({ chekValid, buttonSubmitClick }) => {
                         placeholder='Type Durasi Tempo'
                       />
                     </td>
-                    <td>
+                    <td className='flex flex-row gap-2'>
                       <input
                         name='creditLimit'
                         type='text'
@@ -241,6 +248,10 @@ const Referensi = ({ chekValid, buttonSubmitClick }) => {
                         onChange={(e) => onChangeInput(e, index)}
                         placeholder='Type Credit Limit'
                       />
+                      <Trash2Icon
+                        size={18}
+                        onClick={() => handleDeleteSupplier(index)}
+                      />
                     </td>
                   </tr>
                 ))}
@@ -285,7 +296,7 @@ const Referensi = ({ chekValid, buttonSubmitClick }) => {
                       placeholder='Durasi jatuh tempo'
                     />
                   </td>
-                  <td>
+                  <td className='flex flex-row items-center gap-2 '>
                     <input
                       name='creditLimit'
                       value={formatRupiah(newSupplier.creditLimit)}
@@ -294,6 +305,10 @@ const Referensi = ({ chekValid, buttonSubmitClick }) => {
                       onChange={handleNewSupplierChange}
                       placeholder='limit kredit'
                     />
+                    <Trash2Icon
+                      size={18}
+                      onClick={() => handleDeleteSupplier(index)}
+                    />
                   </td>
                 </tr>
               </tbody>
-- 
cgit v1.2.3

