From b7833ad1d13772ea1dd7a6af6716a2c4b575132a Mon Sep 17 00:00:00 2001
From: Miqdad <ahmadmiqdad27@gmail.com>
Date: Thu, 28 Aug 2025 17:08:20 +0700
Subject: <Miqdad>Hide Beli lagi

---
 src/lib/transaction/components/Transactions.jsx | 55 +++++++++++++++----------
 1 file changed, 33 insertions(+), 22 deletions(-)

(limited to 'src/lib/transaction/components/Transactions.jsx')

diff --git a/src/lib/transaction/components/Transactions.jsx b/src/lib/transaction/components/Transactions.jsx
index dd927dfa..bb24f717 100644
--- a/src/lib/transaction/components/Transactions.jsx
+++ b/src/lib/transaction/components/Transactions.jsx
@@ -69,6 +69,10 @@ const Transactions = ({ context = '' }) => {
   const [contextNew, setcontextNew] = useState(router.query.context || context);
   const [isOpenCalender, setIsOpenCalender] = useState(false);
   const calendarRef = useRef(null);
+  const isUnpaid = (s) =>
+    ['belum_bayar'].includes(
+      String(s || '').toLowerCase()
+    );
 
   // loading id utk tombol lanjutkan transaksi
   const [contLoadingId, setContLoadingId] = useState(null);
@@ -617,18 +621,22 @@ const Transactions = ({ context = '' }) => {
                   </div>
 
                   <div className='flex flex-col gap-2 w-full'>
-                    <button
-                      type='button'
-                      onClick={(e) => {
-                        e.preventDefault();
-                        e.stopPropagation();
-                        handleBuyBack(saleOrder.products);
-                      }}
-                      className='w-full py-2 btn-solid-red text-center rounded-md'
-                    >
-                      Beli Lagi
-                    </button>
+                    {/* Beli Lagi hanya muncul jika status bukan unpaid */}
+                    {!isUnpaid(saleOrder.status) && (
+                      <button
+                        type='button'
+                        onClick={(e) => {
+                          e.preventDefault();
+                          e.stopPropagation();
+                          handleBuyBack(saleOrder.products);
+                        }}
+                        className='w-full py-2 btn-solid-red text-center rounded-md'
+                      >
+                        Beli Lagi
+                      </button>
+                    )}
 
+                    {/* Bayar Sekarang hanya kalau eligible */}
                     {saleOrder?.eligibleContinue && (
                       <button
                         type='button'
@@ -1111,18 +1119,21 @@ const Transactions = ({ context = '' }) => {
                                 </p>
                               </div>
 
-                              <button
-                                type='button'
-                                onClick={(e) => {
-                                  e.preventDefault();
-                                  e.stopPropagation();
-                                  handleBuyBack(saleOrder.products);
-                                }}
-                                className='w-full py-2 btn-solid-red text-nowrap rounded-md'
-                              >
-                                Beli Lagi
-                              </button>
+                              {!isUnpaid(saleOrder.status) && (
+                                <button
+                                  type='button'
+                                  onClick={(e) => {
+                                    e.preventDefault();
+                                    e.stopPropagation();
+                                    handleBuyBack(saleOrder.products);
+                                  }}
+                                  className='w-full py-2 btn-solid-red text-nowrap rounded-md'
+                                >
+                                  Beli Lagi
+                                </button>
+                              )}
 
+                              {/* Bayar Sekarang: hanya kalau eligible */}
                               {saleOrder?.eligibleContinue && (
                                 <button
                                   type='button'
-- 
cgit v1.2.3

