summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/product/components/Product/ProductDesktop.jsx50
1 files changed, 35 insertions, 15 deletions
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 }) => {
</div>
)} */}
- {product?.flashSale?.remainingTime > 0 ? (
+ {lowestPrice?.isFlashsale ? (
<>
<div className='flex gap-x-1 items-center mt-2'>
<div className='badge-solid-red text-caption-1'>
- {lowestPrice?.discountPercentage}%
+ {lowestPrice?.price?.discountPercentage}%
</div>
<div className='text-gray_r-9 line-through text-caption-1'>
- {currencyFormat(lowestPrice?.price)}
+ {currencyFormat(lowestPrice?.price?.price)}
</div>
<div className='text-danger-500 font-semibold text-xl'>
- {currencyFormat(lowestPrice?.priceDiscount)}
+ {currencyFormat(lowestPrice?.price?.priceDiscount)}
</div>
</div>
<div className='text-gray_r-9 text-base font-normal mt-1'>
Termasuk PPN:{' '}
- {currencyFormat(lowestPrice?.priceDiscount * process.env.NEXT_PUBLIC_PPN)}
+ {currencyFormat(lowestPrice?.price.priceDiscount * process.env.NEXT_PUBLIC_PPN)}
</div>
</>
) : (
<h3 className='text-danger-500 font-semibold mt-1 text-title-md'>
- {lowestPrice?.price > 0 ? (
+ {lowestPrice?.price.price > 0 ? (
<>
- {currencyFormat(lowestPrice?.price)}
+ {currencyFormat(lowestPrice?.price.price)}
<div className='text-gray_r-9 text-base font-normal mt-1'>
Termasuk PPN:{' '}
- {currencyFormat(lowestPrice?.price * process.env.NEXT_PUBLIC_PPN)}
+ {currencyFormat(lowestPrice?.price.price * process.env.NEXT_PUBLIC_PPN)}
</div>
</>
) : (
@@ -581,21 +586,36 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
<>
<div className='flex items-center gap-x-1 justify-center'>
<div className='badge-solid-red text-caption-1'>
- {lowestPrice?.discountPercentage}%
+ {variant?.price?.discountPercentage}%
</div>
<div className='line-through text-caption-1 text-gray_r-11'>
- {currencyFormat(variant.price.price)}
+ {currencyFormat(variant?.price?.price)}
</div>{' '}
<div className=' text-caption-1 text-red-600 font-semibold'>
- {currencyFormat(variant.price.priceDiscount)}
+ {currencyFormat(variant?.price?.priceDiscount)}
</div>{' '}
</div>
- {currencyFormat(variant.price.priceDiscount * process.env.NEXT_PUBLIC_PPN)}
+ <div className=' text-caption-1 text-gray_r-11 mb-1'>
+ + PPN:{' '}
+ {currencyFormat(
+ variant.price.priceDiscount * process.env.NEXT_PUBLIC_PPN
+ )}
+ </div>
</>
) : (
<div>
- {variant.price.price > 0 ? (
- currencyFormat(variant.price.price * process.env.NEXT_PUBLIC_PPN)
+ {variant?.price?.price > 0 ? (
+ <>
+ <div className=' text-caption-1 text-red-600 font-semibold'>
+ {currencyFormat(variant?.price?.price)}
+ </div>{' '}
+ <div className=' text-caption-1 text-gray_r-11 mb-1'>
+ + PPN:{' '}
+ {currencyFormat(
+ variant?.price?.priceDiscount * process.env.NEXT_PUBLIC_PPN
+ )}
+ </div>
+ </>
) : (
<a
href={whatsappUrl('product', {