From a040418bdddd5fcaf8a8d67e0a66ea92fd16ee24 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 27 Mar 2023 17:03:28 +0700 Subject: - --- src/core/components/elements/Popup/BottomPopup.jsx | 6 +++--- src/lib/cart/components/Cart.jsx | 4 ++-- src/lib/checkout/components/Checkout.jsx | 23 ++++++++++++++++------ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/core/components/elements/Popup/BottomPopup.jsx b/src/core/components/elements/Popup/BottomPopup.jsx index c244330c..5828d222 100644 --- a/src/core/components/elements/Popup/BottomPopup.jsx +++ b/src/core/components/elements/Popup/BottomPopup.jsx @@ -48,9 +48,9 @@ const BottomPopup = ({ children, active = false, title, close }) => { diff --git a/src/lib/cart/components/Cart.jsx b/src/lib/cart/components/Cart.jsx index d646420c..7ebee14b 100644 --- a/src/lib/cart/components/Cart.jsx +++ b/src/lib/cart/components/Cart.jsx @@ -93,11 +93,11 @@ const Cart = () => { quantity -= value break case 'BLUR': - if (value != '') return + if (value != '' && value > 0) return quantity = 1 break default: - quantity = value + quantity = value != '' && value < 1 ? 1 : value break } productsToUpdate[productIndex].quantity = quantity diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 57d217a7..048bb24e 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -19,6 +19,7 @@ import axios from 'axios' import Image from '@/core/components/elements/Image/Image' import MobileView from '@/core/components/views/MobileView' import DesktopView from '@/core/components/views/DesktopView' +import variantPriceApi from '@/lib/variant/api/variantPriceApi' const Checkout = () => { const router = useRouter() @@ -77,11 +78,21 @@ const Checkout = () => { } const dataProducts = await CartApi({ variantIds }) - const dataProductsQuantity = _.map(dataProducts, (o) => ({ - ...o, - quantity: query.quantity ? query.quantity : getItemCart({ productId: o.id }).quantity - })) - setProducts(dataProductsQuantity) + const productsWithQuantity = dataProducts.map(async (product) => { + const productPrice = await variantPriceApi({ id: product.id }) + return { + ...product, + price: { + price: productPrice.priceExclude, + discountPercentage: productPrice.discount, + priceDiscount: productPrice.priceExcludeAfterDiscount + }, + quantity: query.quantity ? query.quantity : getItemCart({ productId: product.id }).quantity + } + }) + Promise.all(productsWithQuantity).then((resolvedProducts) => { + setProducts(resolvedProducts) + }) } loadProducts() }, [router]) @@ -439,7 +450,7 @@ const Checkout = () => {

Ukuran dokumen PO Maksimal 5MB


- +