From 7ed2913450713655d2e962846d795dc6b4091de4 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 27 Mar 2023 15:17:59 +0700 Subject: cart --- src/lib/address/components/Addresses.jsx | 2 +- src/lib/cart/components/Cart.jsx | 13 +++++++++++-- src/lib/category/components/Category.jsx | 6 +++--- src/lib/invoice/components/Invoice.jsx | 9 +-------- src/lib/product/components/Product/ProductDesktop.jsx | 8 ++++++-- src/lib/product/components/ProductFilterDesktop.jsx | 2 -- src/lib/transaction/components/Transaction.jsx | 6 +++--- 7 files changed, 25 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/lib/address/components/Addresses.jsx b/src/lib/address/components/Addresses.jsx index a2adecb1..db338983 100644 --- a/src/lib/address/components/Addresses.jsx +++ b/src/lib/address/components/Addresses.jsx @@ -61,7 +61,7 @@ const Addresses = () => {

Daftar Alamat

- + Tambah Alamat
diff --git a/src/lib/cart/components/Cart.jsx b/src/lib/cart/components/Cart.jsx index 8cd6df96..d646420c 100644 --- a/src/lib/cart/components/Cart.jsx +++ b/src/lib/cart/components/Cart.jsx @@ -14,6 +14,7 @@ import Spinner from '@/core/components/elements/Spinner/Spinner' import Alert from '@/core/components/elements/Alert/Alert' import MobileView from '@/core/components/views/MobileView' import DesktopView from '@/core/components/views/DesktopView' +import variantPriceApi from '@/lib/variant/api/variantPriceApi' const Cart = () => { const router = useRouter() @@ -28,16 +29,24 @@ const Cart = () => { useEffect(() => { if (cart.data && !products) { - const productsWithQuantity = cart.data.map((product) => { + const productsWithQuantity = cart.data.map(async (product) => { const productInCart = getItemCart({ productId: product.id }) if (!productInCart) return + const productPrice = await variantPriceApi({ id: product.id }) return { ...product, + price: { + price: productPrice.priceExclude, + discountPercentage: productPrice.discount, + priceDiscount: productPrice.priceExcludeAfterDiscount + }, quantity: productInCart.quantity, selected: productInCart.selected } }) - setProducts(productsWithQuantity) + Promise.all(productsWithQuantity).then((resolvedProducts) => { + setProducts(resolvedProducts) + }) } }, [cart, products]) diff --git a/src/lib/category/components/Category.jsx b/src/lib/category/components/Category.jsx index 5ba45cc7..9f34362c 100644 --- a/src/lib/category/components/Category.jsx +++ b/src/lib/category/components/Category.jsx @@ -32,7 +32,7 @@ const Category = () => { {categories.map((category) => (
{category.name} @@ -42,7 +42,7 @@ const Category = () => { {category.childs.map((child1Category) => (
{child1Category.name} @@ -50,7 +50,7 @@ const Category = () => {
{child1Category.childs.map((child2Category) => ( diff --git a/src/lib/invoice/components/Invoice.jsx b/src/lib/invoice/components/Invoice.jsx index 355f36e5..211d1ae1 100644 --- a/src/lib/invoice/components/Invoice.jsx +++ b/src/lib/invoice/components/Invoice.jsx @@ -153,14 +153,7 @@ const Invoice = ({ id }) => {
Purchase Order
- :{' '} - + : {invoice?.data?.purchaseOrderName || '-'}
Ketentuan Pembayaran
diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index 663d5a74..2f73d124 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -125,7 +125,7 @@ const ProductDesktop = ({ product, wishlist, toggleWishlist }) => { {productPrice?.data?.priceExcludeAfterDiscount > 0 ? ( currencyFormat(productPrice?.data?.priceExcludeAfterDiscount) ) : ( - + Hubungi kami untuk dapatkan harga terbaik,  klik disini @@ -261,7 +261,11 @@ const VariantPrice = ({ id }) => { {' '} )} - {currencyFormat(variantPrice?.data?.priceExcludeAfterDiscount)} + {variantPrice?.data?.priceExcludeAfterDiscount > 0 ? ( + currencyFormat(variantPrice?.data?.priceExcludeAfterDiscount) + ) : ( + Call for price + )} ) } diff --git a/src/lib/product/components/ProductFilterDesktop.jsx b/src/lib/product/components/ProductFilterDesktop.jsx index e430ac58..ce6c12ed 100644 --- a/src/lib/product/components/ProductFilterDesktop.jsx +++ b/src/lib/product/components/ProductFilterDesktop.jsx @@ -32,8 +32,6 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu } } - console.log('branddddd', defaultBrand) - const handleSubmit = () => { let params = { q: router.query.q, diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index 104a7f2d..b921eb0d 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -260,7 +260,7 @@ const Transaction = ({ id }) => { @@ -292,7 +292,7 @@ const Transaction = ({ id }) => { type='button' className='btn-solid-red px-3 py-2' disabled={transaction.data?.status != 'draft'} - onClick={downloadQuotation} + onClick={() => downloadQuotation(transaction.data)} > Download @@ -547,7 +547,7 @@ const SectionContent = ({ address }) => { const DescriptionRow = ({ children, label }) => (
{label} - {children} + {children}
) -- cgit v1.2.3