From ebf4faee910b591254b27b99be68e2e0cb6d31ae Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Wed, 22 May 2024 10:34:58 +0700 Subject: list site & button download --- src/lib/transaction/components/Transactions.jsx | 60 ++++++++++++++----------- 1 file changed, 35 insertions(+), 25 deletions(-) (limited to 'src/lib/transaction') diff --git a/src/lib/transaction/components/Transactions.jsx b/src/lib/transaction/components/Transactions.jsx index 9485449d..1a57a976 100644 --- a/src/lib/transaction/components/Transactions.jsx +++ b/src/lib/transaction/components/Transactions.jsx @@ -26,6 +26,7 @@ import MobileView from '@/core/components/views/MobileView'; import DesktopView from '@/core/components/views/DesktopView'; import Menu from '@/lib/auth/components/Menu'; import * as XLSX from 'xlsx'; +import getSite from '../api/listSiteApi'; const Transactions = ({ context = '' }) => { const auth = useAuth(); @@ -37,6 +38,7 @@ const Transactions = ({ context = '' }) => { const [inputQuery, setInputQuery] = useState(q); const [toOthers, setToOthers] = useState(null); const [toCancel, setToCancel] = useState(null); + const [listSites, setListSites] = useState([]); const [siteFilter, setSiteFilter] = useState(site); @@ -51,6 +53,11 @@ const Transactions = ({ context = '' }) => { const { transactions } = useTransactions({ query }); + const fetchSite = async () => { + const site = await getSite(); + setListSites(site.sites); + }; + const submitCancelTransaction = async () => { const isCancelled = await cancelTransactionApi({ transaction: toCancel, @@ -108,13 +115,13 @@ const Transactions = ({ context = '' }) => { const row = { 'No. Transaksi': saleOrder.name, 'No. PO': saleOrder.purchaseOrderName || '-', - 'Tanggal': saleOrder.dateOrder || '-', + Tanggal: saleOrder.dateOrder || '-', 'Created By': saleOrder.address.customer?.name || '-', - 'Salesperson': saleOrder.sales, - 'Total': currencyFormat(saleOrder.amountTotal), - 'Status': saleOrder.status, + Salesperson: saleOrder.sales, + Total: currencyFormat(saleOrder.amountTotal), + Status: saleOrder.status, }; - if(siteFilter){ + if (siteFilter) { row['Site'] = siteFilter; } rowsToExport.push(row); @@ -134,6 +141,10 @@ const Transactions = ({ context = '' }) => { exportToExcel(dataToExport, siteFilter); }; + + useEffect(() => { + fetchSite(); + }, []); return ( <> @@ -304,7 +315,7 @@ const Transactions = ({ context = '' }) => {
-
+

Daftar Transaksi{' '} {transactions?.data?.saleOrders @@ -312,16 +323,21 @@ const Transactions = ({ context = '' }) => { : ''}

- + {listSites.length > 0 && ( + + )} +
{
-- cgit v1.2.3