From 5c36cea8bccd9a9c06f61d82314af398afe0875f Mon Sep 17 00:00:00 2001
From: trisusilo48 <tri.susilo@altama.co.id>
Date: Tue, 3 Sep 2024 11:01:30 +0700
Subject: fixing feedback pak iwan (point 5)

---
 src/lib/checkout/components/Checkout.jsx | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

(limited to 'src/lib/checkout/components/Checkout.jsx')

diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx
index 54acdf7c..22265734 100644
--- a/src/lib/checkout/components/Checkout.jsx
+++ b/src/lib/checkout/components/Checkout.jsx
@@ -174,7 +174,6 @@ const Checkout = () => {
           }
           return; // Hentikan eksekusi lebih lanjut pada iterasi ini
         }
-
         // Memeriksa apakah subtotal memenuhi syarat minimal pembelian
         if (cartCheckout?.subtotal < addNewLine.minPurchaseAmount) {
           SetSelisihHargaCode(
@@ -191,7 +190,9 @@ const Checkout = () => {
 
         // Tambahkan voucher ke list dan set voucher aktif
         SetListVoucher((prevList) => [addNewLine, ...prevList]);
-        SetActiveVoucher(addNewLine.code);
+        if (addNewLine.canApply) {
+          SetActiveVoucher(addNewLine.code);
+        }
       } else {
         // Mencari voucher dalam listVoucherShippings
         let checkList = listVoucherShippings?.findIndex(
@@ -227,7 +228,9 @@ const Checkout = () => {
 
         // Tambahkan voucher ke list pengiriman dan set voucher aktif pengiriman
         SetListVoucherShipping((prevList) => [addNewLine, ...prevList]);
-        setActiveVoucherShipping(addNewLine.code);
+        if (addNewLine.canApply) {
+          setActiveVoucherShipping(addNewLine.code);
+        }
       }
     });
 
@@ -701,7 +704,9 @@ const Checkout = () => {
 
           {listVoucherShippings && listVoucherShippings?.length > 0 && (
             <div>
-              <h3 className='font-semibold mb-4'>Promo Extra Potongan Ongkir</h3>
+              <h3 className='font-semibold mb-4'>
+                Promo Extra Potongan Ongkir
+              </h3>
               {listVoucherShippings?.map((item) => (
                 <div key={item.id} className='relative'>
                   <div
-- 
cgit v1.2.3

