diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-03-27 17:03:28 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-03-27 17:03:28 +0700 |
| commit | a040418bdddd5fcaf8a8d67e0a66ea92fd16ee24 (patch) | |
| tree | 22be75fe02bf75dfafa7c82b0eef2187b186f86a /src/lib/checkout/components/Checkout.jsx | |
| parent | 7ed2913450713655d2e962846d795dc6b4091de4 (diff) | |
-
Diffstat (limited to 'src/lib/checkout/components/Checkout.jsx')
| -rw-r--r-- | src/lib/checkout/components/Checkout.jsx | 23 |
1 files changed, 17 insertions, 6 deletions
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 = () => { <p className='text-caption-2 text-gray_r-11 mt-2'>Ukuran dokumen PO Maksimal 5MB</p> <hr className='my-4 border-gray_r-6' /> - + <button className='w-full btn-yellow mt-4' onClick={checkout} |
