From dc204e9cdbcf7faf81dba825db608be2c918589d Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 9 Jul 2024 16:31:30 +0700 Subject: { + const router = useRouter() + const [isModalOpen, setIsModalOpen] = useState(false); + const [selectedProduct, setSelectedProduct] = useState(null); + const [reason, setReason] = useState(''); const auth = useAuth(); const { transaction } = useTransaction({ id }); - const statusApprovalWeb = transaction.data?.approvalStep - const { queryAirwayBill } = useAirwayBill({ orderId: id }); const [airwayBillPopup, setAirwayBillPopup] = useState(null); @@ -151,6 +155,38 @@ const Transaction = ({ id }) => { setIdAWB(null); }; + const openModal = (product) => { + setSelectedProduct(product); + setIsModalOpen(true); + }; + + const closeModal = () => { + setIsModalOpen(false); + setSelectedProduct(null); + setReason(''); + }; + + const handleRejectProduct = async () => { + try{ + if (!reason.trim()) { + toast.error('Masukkan alasan terlebih dahulu'); + return; + }else{ + let idSo = transaction?.data.id + let idProduct = selectedProduct?.id + await rejectProductApi({ idSo, idProduct, reason}); + closeModal(); + toast.success("Produk berhasil di reaject") + setTimeout(() => { + window.location.reload(); + }, 1500); + } + }catch(error){ + toast.error('Gagal reject produk. Silakan coba lagi.'); + } + }; + + return ( transaction.data?.name && ( <> @@ -566,6 +602,7 @@ const Transaction = ({ id }) => { Jumlah Harga Subtotal + @@ -620,10 +657,61 @@ const Transaction = ({ id }) => {
{currencyFormat(product.price.priceDiscount)}
{currencyFormat(product.price.subtotal)} + {/* {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (transaction.data.isReaject == false) && ( */} + {auth?.feature.soApproval && (auth.webRole == 2 || auth.webRole == 3) && (router.asPath.includes("/my/quotations/")) && ( + + + + )} + {/* {transaction.data.isReaject && ( + + + + )} */} ))} + {isModalOpen && ( +
+
+

Berikan Alasan

+ +
+ + +
+
+
+ )}
-- cgit v1.2.3 From e3d0de0ba20eee9d53e95c5525907b099d2b5b04 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 10 Jul 2024 14:20:29 +0700 Subject: update reaject button & component position --- src/lib/transaction/components/Transaction.jsx | 316 ++++++++++++++++--------- 1 file changed, 207 insertions(+), 109 deletions(-) (limited to 'src/lib/transaction/components') diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index 03c94ded..8e7cede0 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -143,6 +143,15 @@ const Transaction = ({ id }) => { [transaction.data] ); + const memoizeVariantGroupCardReject = useMemo( + () => ( +
+ +
+ ), + [transaction.data] + ); + if (transaction.isLoading) { return (
@@ -176,7 +185,7 @@ const Transaction = ({ id }) => { let idProduct = selectedProduct?.id await rejectProductApi({ idSo, idProduct, reason}); closeModal(); - toast.success("Produk berhasil di reaject") + toast.success("Produk berhasil di reject") setTimeout(() => { window.location.reload(); }, 1500); @@ -329,6 +338,37 @@ const Transaction = ({ id }) => { +
+

Invoice

+
+ {transaction.data?.invoices?.map((invoice, index) => ( + +
+
+

{invoice?.name}

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

+ {currencyFormat(invoice.amountTotal)} +

+
+
+ +
+ + ))} + {transaction.data?.invoices?.length === 0 && ( +
Belum ada invoice
+ )} +
+
+ + + {!auth?.feature.soApproval && (
@@ -354,8 +394,20 @@ const Transaction = ({ id }) => {
Detail Produk
+ {transaction?.data?.products.length > 0? ( +
+ {memoizeVariantGroupCard} +
+ ) : ( +
Semua produk telah di reject
+ )} - {memoizeVariantGroupCard} + {transaction?.data?.productsRejectLine.length > 0 && ( +
+
Detail Produk Reject
+ {memoizeVariantGroupCardReject} +
+ )} @@ -363,37 +415,6 @@ const Transaction = ({ id }) => { -
-

Invoice

-
- {transaction.data?.invoices?.map((invoice, index) => ( - -
-
-

{invoice?.name}

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

- {currencyFormat(invoice.amountTotal)} -

-
-
- -
- - ))} - {transaction.data?.invoices?.length === 0 && ( -
Belum ada invoice
- )} -
-
- - -
{transaction.data?.status == 'draft' && auth?.feature.soApproval && (
@@ -561,51 +582,83 @@ const Transaction = ({ id }) => { />
- -
- Pengiriman -
-
- {transaction?.data?.pickings?.map((airway) => ( - + ))} +
+
+
+
Invoice
+ {transaction.data?.invoices?.length === 0 && ( +
Belum ada invoice
+ )} +
+ {transaction.data?.invoices?.map((invoice, index) => ( + +
+
+

{invoice?.name}

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

+ {currencyFormat(invoice.amountTotal)} +

+
+
+ +
+ + ))}
- - ))} +
- {transaction?.data?.pickings.length == 0 && ( -
Belum ada pengiriman
- )} -
+
Rincian Pembelian
- - - - - {/* */} - - - - - - - + {transaction?.data?.products?.length > 0? ( +
Nama ProdukDiskonJumlahHargaSubtotal
+ + + + {/* */} + + + + + + + {transaction?.data?.products?.map((product) => ( )} - {/* {transaction.data.isReaject && ( - - )} */} ))}
Nama ProdukDiskonJumlahHargaSubtotal
@@ -668,21 +721,14 @@ const Transaction = ({ id }) => { - -
+ ) : ( +
Semua produk telah di reject
+ )} + {isModalOpen && (
Subtotal
@@ -738,33 +785,84 @@ const Transaction = ({ id }) => {
+ ))} -
Invoice
-
- {transaction.data?.invoices?.map((invoice, index) => ( - -
-
-

{invoice?.name}

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

- {currencyFormat(invoice.amountTotal)} -

-
-
- -
- - ))} -
- {transaction.data?.invoices?.length === 0 && ( -
Belum ada invoice
+ + + {transaction?.data?.productsRejectLine.length > 0 && ( +
+ Rincian Produk Reject +
+ )} + {transaction?.data?.productsRejectLine.length > 0 && ( + + + + + {/* */} + + + + + + + {transaction?.data?.productsRejectLine?.map((product) => ( + + + {/* */} + + + + + ))} + +
Nama ProdukDiskonJumlahHargaSubtotal
+ + {product?.name} + +
+ + {product?.parent?.name} + +
+ {product?.code}{' '} + {product?.attributes.length > 0 + ? `| ${product?.attributes.join(', ')}` + : ''} +
+
+
+ {product.price.discountPercentage > 0 + ? `${product.price.discountPercentage}%` + : ''} + {product.quantity} + {/* {product.price.discountPercentage > 0 && ( +
+ {currencyFormat(product.price.price)} +
+ )} */} +
{currencyFormat(product.price.priceDiscount)}
+
{currencyFormat(product.quantity * product.price.priceDiscount)}
)} +
-- cgit v1.2.3