From f4adb008ae55e4b340c58c32d45af6d0eaf6eb57 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 12 Mar 2025 14:29:42 +0700 Subject: update detail transaction --- src/lib/transaction/components/Transaction.jsx | 278 +++++++++++++++++++++++-- 1 file changed, 260 insertions(+), 18 deletions(-) (limited to 'src/lib/transaction/components/Transaction.jsx') diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index b2fb2c17..32416bc0 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -49,18 +49,19 @@ const Transaction = ({ id }) => { const [reason, setReason] = useState(''); const auth = useAuth(); const { transaction } = useTransaction({ id }); + console.log('transaction', transaction); const statusApprovalWeb = transaction.data?.approvalStep; const [isLoading, setIsLoading] = useState(false); const { queryAirwayBill } = useAirwayBill({ orderId: id }); const [airwayBillPopup, setAirwayBillPopup] = useState(null); - + const [isOpen, setIsOpen] = useState(false); const poNumber = useRef(null); const poFile = useRef(null); const [uploadPo, setUploadPo] = useState(false); const [idAWB, setIdAWB] = useState(null); const openUploadPo = () => setUploadPo(true); const closeUploadPo = () => setUploadPo(false); - + const [copied, setCopied] = useState(false); const submitUploadPo = async () => { const file = poFile.current.files[0]; const name = poNumber.current.value; @@ -208,7 +209,9 @@ const Transaction = ({ id }) => {

{currencyFormat(transaction.data?.amountUntaxed)}

-

PPN {((PPN - 1) * 100).toFixed(0)}%

+

+ PPN {((PPN - 1) * 100).toFixed(0)}% +

{currencyFormat(transaction.data?.amountTax)}

@@ -279,6 +282,35 @@ const Transaction = ({ id }) => { } }; + const handleCopyClick = (waybillNumber) => { + const textToCopy = waybillNumber; + console.log('textToCopy', textToCopy); + navigator.clipboard.writeText(textToCopy); + setCopied(true); + toast.success('No Resi Berhasil di Copy'); + setTimeout(() => setCopied(false), 2000); // Reset copied state after 2 seconds + }; + + const formatDate = (dateString) => { + const months = [ + 'Januari', + 'Februari', + 'Maret', + 'April', + 'Mei', + 'Juni', + 'Juli', + 'Agustus', + 'September', + 'Oktober', + 'November', + 'Desember', + ]; + + const [day, month, year] = dateString.split('/'); + return `${day} ${months[parseInt(month, 10) - 1]} ${year}`; + }; + return ( transaction.data?.name && ( <> @@ -615,13 +647,50 @@ const Transaction = ({ id }) => { )}
-
- - {transaction?.data?.name} - - +
+
-
+
+
+ + {transaction?.data?.name} + + +
+
+
+ +
+
+
+ {/*
)} -
+
*/}
-
+
Nama Sales
: {transaction?.data?.sales}
Tanggal Transaksi
: {transaction?.data?.dateOrder}
-
-
-
Ketentuan Pembayaran
-
: {transaction?.data?.paymentTerm}
{!auth?.feature?.soApproval ? ( <> @@ -729,9 +794,184 @@ const Transaction = ({ id }) => { )}
+
+
Payment Term
+
: {transaction?.data?.paymentTerm}
+ +
Dokumen Pengiriman
+
+ :{' '} + {transaction.data?.pickings?.length === 0 + ? 'Belum ada pengiriman' + : transaction?.data?.pickings[0].name} +
+ +
Invoice Pembelian
+
+ :{' '} + {transaction.data?.invoices?.length === 0 + ? 'Belum ada invoice' + : transaction.data?.invoices?.map((invoice, index) => ( + + {invoice?.name} + {/*
+
+

{invoice?.name}

+
+ {invoice.amountResidual > 0 ? ( +
Belum Lunas
+ ) : ( +
Lunas
+ )} +

+ {currencyFormat(invoice.amountTotal)} +

+
+
+ +
*/} + + ))} +
+
+
+
+ {/*
*/} +
+
+ + Alamat Pengiriman + +
+
Nama Penerima
+
:
+
{transaction?.data?.address?.customer?.name}
+ +
No. Telepon
+
:
+
{transaction?.data?.address?.customer?.phone}
+ +
Email
+
:
+
{transaction?.data?.address?.customer?.email}
+ +
Alamat Pengiriman
+
:
+
+ {transaction?.data?.address?.customer?.alamatBisnis} +
+
+
+
+ + Info Pengiriman + +
+
Nomor Resi
+
:
+
+ {transaction?.data?.pickings[0]?.trackingNumber || '-'} + {transaction?.data?.pickings[0]?.trackingNumber && ( + + )} +
+ +
Kurir
+
:
+
+ {transaction?.data?.pickings[0]?.carrierName ? ( + <> +

{transaction?.data?.pickings[0]?.carrierName}

+ + setIdAWB(transaction?.data?.pickings[0]?.id) + } + > + Lacak Pengiriman + + + ) : ( + '-' + )} +
+ +
Jenis Service
+
:
+
BELUM TAU AMBIL DARI MANA
+ +
Tanggal Kirim
+
:
+
+ {transaction?.data?.pickings[0]?.date + ? formatDate(transaction?.data?.pickings[0]?.date) + : '-'} +
+ +
Estimasi Tiba
+
:
+
+ {transaction?.data?.pickings[0]?.eta + ? transaction?.data?.pickings[0]?.eta + : '-'} +
+ {transaction?.data?.pickings[0] && ( +
+ +
+ )} +
+
-
+
+ + {/*
Informasi Pelanggan
@@ -807,7 +1047,7 @@ const Transaction = ({ id }) => { ))}
-
+
*/}
Rincian Pembelian @@ -976,7 +1216,9 @@ const Transaction = ({ id }) => { {currencyFormat(transaction.data?.amountUntaxed)}
-
PPN {((PPN - 1) * 100).toFixed(0)}%
+
+ PPN {((PPN - 1) * 100).toFixed(0)}% +
{currencyFormat(transaction.data?.amountTax)}
-- cgit v1.2.3