From fdfb47c3a825258b871ac5921605642e5e05fdd8 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Tue, 21 Feb 2023 12:04:20 +0700
Subject: fix

---
 src/lib/transaction/components/Transactions.jsx | 32 +++++++++++++++----------
 1 file changed, 19 insertions(+), 13 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 5eb1d947..246a4a2c 100644
--- a/src/lib/transaction/components/Transactions.jsx
+++ b/src/lib/transaction/components/Transactions.jsx
@@ -14,6 +14,7 @@ import BottomPopup from "@/core/components/elements/Popup/BottomPopup"
 import Pagination from "@/core/components/elements/Pagination/Pagination"
 import { toQuery } from "lodash-contrib"
 import _ from "lodash"
+import Alert from "@/core/components/elements/Alert/Alert"
 
 const Transactions = () => {
   const router = useRouter()
@@ -29,24 +30,22 @@ const Transactions = () => {
     offset: (page - 1) * limit,
     limit
   }
-
-  const [ inputQuery, setInputQuery ] = useState(q)
-
   const { transactions } = useTransactions({ query })
 
+  const [ inputQuery, setInputQuery ] = useState(q)
   const [ toOthers, setToOthers ] = useState(null)
-  const [ toDelete, setToDelete ] = useState(null)
+  const [ toCancel, setToCancel ] = useState(null)
 
   const submitCancelTransaction = async () => {
     const isCancelled = await cancelTransactionApi({
       partnerId: auth.partnerId,
-      transaction: toDelete
+      transaction: toCancel
     })
     if (isCancelled) {
       toast.success('Berhasil batalkan transaksi')
       transactions.refetch()
     }
-    setToDelete(null)
+    setToCancel(null)
   }
 
   const pageCount = Math.ceil(transactions?.data?.saleOrderTotal / limit)
@@ -82,6 +81,13 @@ const Transactions = () => {
             <Spinner className="w-6 text-gray_r-12/50 fill-gray_r-12" />
           </div>
         ) }
+
+        { !transactions.isLoading && transactions.data?.saleOrders?.length === 0 && (
+          <Alert type="info" className="text-center">
+            Tidak ada data transaksi
+          </Alert>
+        ) }
+
         { transactions.data?.saleOrders?.map((saleOrder, index) => (
           <div className="p-4 shadow border border-gray_r-3 rounded-md" key={index}>
             <div className="grid grid-cols-2">
@@ -132,21 +138,21 @@ const Transactions = () => {
           <button 
             className="text-left disabled:opacity-60"
             disabled={!toOthers?.purchaseOrderFile}
-            onClick={() => { downloadPurchaseOrder(auth.partnerId, toOthers); setToOthers(null) }}
+            onClick={() => { downloadPurchaseOrder(toOthers); setToOthers(null) }}
           >
             Download PO
           </button>
           <button 
             className="text-left disabled:opacity-60"
             disabled={toOthers?.status != 'draft'}
-            onClick={() => { downloadQuotation(auth.partnerId, toOthers); setToOthers(null) }}
+            onClick={() => { downloadQuotation(toOthers); setToOthers(null) }}
           >
             Download Quotation
           </button>
           <button 
             className="text-left disabled:opacity-60" 
             disabled={ toOthers?.status != 'waiting' }
-            onClick={() => { setToDelete(toOthers); setToOthers(null) }}
+            onClick={() => { setToCancel(toOthers); setToOthers(null) }}
           >
             Batalkan Transaksi
           </button>
@@ -154,12 +160,12 @@ const Transactions = () => {
       </BottomPopup>
 
       <BottomPopup
-        active={toDelete}
-        close={() => setToDelete(null)}
+        active={toCancel}
+        close={() => setToCancel(null)}
         title="Batalkan Transaksi"
       >
         <div className="leading-7 text-gray_r-12/80">
-          Apakah anda yakin membatalkan transaksi <span className="underline">{toDelete?.name}</span>?
+          Apakah anda yakin membatalkan transaksi <span className="underline">{toCancel?.name}</span>?
         </div>
         <div className="flex mt-6 gap-x-4">
           <button 
@@ -172,7 +178,7 @@ const Transactions = () => {
           <button 
             className="btn-light flex-1" 
             type="button"
-            onClick={() => setToDelete(null)}
+            onClick={() => setToCancel(null)}
           >
             Batal
           </button>
-- 
cgit v1.2.3

