diff options
| author | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-10-04 11:35:03 +0700 |
|---|---|---|
| committer | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-10-04 11:35:03 +0700 |
| commit | 5624207e88c272a8edde9c334393bca5ac20d3fc (patch) | |
| tree | 4005bd98c0bb130f65b86f0b6c7f34fc6e823d2d | |
| parent | eb7bea2f262ffa4faa39d4f163950892c5640c0f (diff) | |
ketingaalan
| -rw-r--r-- | src/lib/product/components/Product/ProductDesktop.jsx | 50 |
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', { |
