From 5624207e88c272a8edde9c334393bca5ac20d3fc Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Wed, 4 Oct 2023 11:35:03 +0700 Subject: ketingaalan --- .../product/components/Product/ProductDesktop.jsx | 50 +++++++++++++++------- 1 file changed, 35 insertions(+), 15 deletions(-) (limited to 'src/lib') diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index 30424943..16ff31aa 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -44,8 +44,13 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { const { setRefreshCart, refreshCart } = useProductCartContext() const getLowestPrice = useCallback(() => { - const prices = product.variants.map((variant) => variant.price) + const prices = product.variants.map((variant) => ({ + price: variant.price, + isFlashsale: variant.isFlashsale + })) const lowest = prices.reduce((lowest, price) => { + console.log('ini reduce lowest', lowest) + console.log('ini reduce price', price) return price.priceDiscount < lowest.priceDiscount ? price : lowest }, prices[0]) return lowest @@ -438,32 +443,32 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { )} */} - {product?.flashSale?.remainingTime > 0 ? ( + {lowestPrice?.isFlashsale ? ( <>
- {lowestPrice?.discountPercentage}% + {lowestPrice?.price?.discountPercentage}%
- {currencyFormat(lowestPrice?.price)} + {currencyFormat(lowestPrice?.price?.price)}
- {currencyFormat(lowestPrice?.priceDiscount)} + {currencyFormat(lowestPrice?.price?.priceDiscount)}
Termasuk PPN:{' '} - {currencyFormat(lowestPrice?.priceDiscount * process.env.NEXT_PUBLIC_PPN)} + {currencyFormat(lowestPrice?.price.priceDiscount * process.env.NEXT_PUBLIC_PPN)}
) : (

- {lowestPrice?.price > 0 ? ( + {lowestPrice?.price.price > 0 ? ( <> - {currencyFormat(lowestPrice?.price)} + {currencyFormat(lowestPrice?.price.price)}
Termasuk PPN:{' '} - {currencyFormat(lowestPrice?.price * process.env.NEXT_PUBLIC_PPN)} + {currencyFormat(lowestPrice?.price.price * process.env.NEXT_PUBLIC_PPN)}
) : ( @@ -581,21 +586,36 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { <>
- {lowestPrice?.discountPercentage}% + {variant?.price?.discountPercentage}%
- {currencyFormat(variant.price.price)} + {currencyFormat(variant?.price?.price)}
{' '}
- {currencyFormat(variant.price.priceDiscount)} + {currencyFormat(variant?.price?.priceDiscount)}
{' '}
- {currencyFormat(variant.price.priceDiscount * process.env.NEXT_PUBLIC_PPN)} +
+ + PPN:{' '} + {currencyFormat( + variant.price.priceDiscount * process.env.NEXT_PUBLIC_PPN + )} +
) : (
- {variant.price.price > 0 ? ( - currencyFormat(variant.price.price * process.env.NEXT_PUBLIC_PPN) + {variant?.price?.price > 0 ? ( + <> +
+ {currencyFormat(variant?.price?.price)} +
{' '} +
+ + PPN:{' '} + {currencyFormat( + variant?.price?.priceDiscount * process.env.NEXT_PUBLIC_PPN + )} +
+ ) : (