diff options
5 files changed, 48 insertions, 35 deletions
diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index 0df60673..30424943 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -452,7 +452,8 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { </div> </div> <div className='text-gray_r-9 text-base font-normal mt-1'> - Termasuk PPN: {currencyFormat(lowestPrice?.priceDiscount * process.env.NEXT_PUBLIC_PPN)} + Termasuk PPN:{' '} + {currencyFormat(lowestPrice?.priceDiscount * process.env.NEXT_PUBLIC_PPN)} </div> </> ) : ( @@ -461,7 +462,8 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { <> {currencyFormat(lowestPrice?.price)} <div className='text-gray_r-9 text-base font-normal mt-1'> - Termasuk PPN: {currencyFormat(lowestPrice?.price * process.env.NEXT_PUBLIC_PPN)} + Termasuk PPN:{' '} + {currencyFormat(lowestPrice?.price * process.env.NEXT_PUBLIC_PPN)} </div> </> ) : ( @@ -575,32 +577,50 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { <ColumnsSLA variant={variant} product={product} /> </LazyLoadComponent> <td> - {variant.price.discountPercentage > 0 && + {variant.isFlashsale ? ( + <> + <div className='flex items-center gap-x-1 justify-center'> + <div className='badge-solid-red text-caption-1'> + {lowestPrice?.discountPercentage}% + </div> + <div className='line-through text-caption-1 text-gray_r-11'> + {currencyFormat(variant.price.price)} + </div>{' '} + <div className=' text-caption-1 text-red-600 font-semibold'> + {currencyFormat(variant.price.priceDiscount)} + </div>{' '} + </div> + {currencyFormat(variant.price.priceDiscount * process.env.NEXT_PUBLIC_PPN)} + </> + ) : ( + <div> + {variant.price.price > 0 ? ( + currencyFormat(variant.price.price * process.env.NEXT_PUBLIC_PPN) + ) : ( + <a + href={whatsappUrl('product', { + name: variant.name, + manufacture: product.manufacture?.name, + url: createSlug('/shop/product/', product.name, product.id, true) + })} + className='text-red_r-11' + rel='noopener noreferrer' + target='_blank' + > + Call for price + </a> + )} + </div> + )} + {/* {variant.price.discountPercentage > 0 && variant.price.priceDiscount > 0 && ( <> <div className='line-through text-caption-1 text-gray_r-11 mb-1'> {currencyFormat(variant.price.price)} </div>{' '} </> - )} - <div> - {variant.price.priceDiscount > 0 ? ( - currencyFormat(variant.price.priceDiscount) - ) : ( - <a - href={whatsappUrl('product', { - name: variant.name, - manufacture: product.manufacture?.name, - url: createSlug('/shop/product/', product.name, product.id, true) - })} - className='text-red_r-11' - rel='noopener noreferrer' - target='_blank' - > - Call for price - </a> - )} - </div> + )} */} + {/* <VariantPrice id={variant.id} /> */} </td> <td> diff --git a/src/lib/product/components/Product/ProductMobile.jsx b/src/lib/product/components/Product/ProductMobile.jsx index a9d34683..94312d31 100644 --- a/src/lib/product/components/Product/ProductMobile.jsx +++ b/src/lib/product/components/Product/ProductMobile.jsx @@ -152,8 +152,6 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => { router.push(`/shop/checkout?source=buy`) } - console.log('ini log', activeVariant) - const productSimilarQuery = [ product?.name, `fq=-product_id_i:${product.id}`, diff --git a/src/lib/product/components/Product/ProductMobileVariant.jsx b/src/lib/product/components/Product/ProductMobileVariant.jsx index a7b1a543..8cdb631f 100644 --- a/src/lib/product/components/Product/ProductMobileVariant.jsx +++ b/src/lib/product/components/Product/ProductMobileVariant.jsx @@ -82,7 +82,6 @@ const ProductMobileVariant = ({ product, wishlist, toggleWishlist }) => { }) setAddCartAlert(true) } - console.log('ini log', activeVariant) const handleClickBuy = () => { if (!validAction()) return diff --git a/src/lib/variant/components/VariantGroupCard.jsx b/src/lib/variant/components/VariantGroupCard.jsx index dd5983a9..1e921546 100644 --- a/src/lib/variant/components/VariantGroupCard.jsx +++ b/src/lib/variant/components/VariantGroupCard.jsx @@ -4,7 +4,6 @@ import Image from '@/core/components/elements/Image/Image' import currencyFormat from '@/core/utils/currencyFormat' const VariantGroupCard = ({ variants, ...props }) => { - console.log('variant', variants) const [showAll, setShowAll] = useState(false) const variantsToShow = showAll ? variants : variants.slice(0, 2) diff --git a/src/pages/api/shop/product-detail.js b/src/pages/api/shop/product-detail.js index 5c3a8231..23adcb5f 100644 --- a/src/pages/api/shop/product-detail.js +++ b/src/pages/api/shop/product-detail.js @@ -26,17 +26,19 @@ export default async function handler(req, res) { const productResponseMap = (products, pricelist) => { return products.map((product) => { - let price = product.price_f || 0 + let price = product.price_tier1_v2_f || 0 let priceDiscount = product.price_discount_f || 0 let discountPercentage = product.discount_f || 0 if (pricelist) { - const pricelistDiscount = product?.[`price_${pricelist}_f`] || false + /*const pricelistDiscount = product?.[`price_${pricelist}_f`] || false const pricelistDiscountPerc = product?.[`discount_${pricelist}_f`] || false if (pricelistDiscount && pricelistDiscount > 0) priceDiscount = pricelistDiscount if (pricelistDiscountPerc && pricelistDiscountPerc > 0) discountPercentage = pricelistDiscountPerc + */ + price = product?.[`price_${pricelist}_v2_f`] || 0 } if (product?.flashsale_id_i > 0) { @@ -86,17 +88,12 @@ const productResponseMap = (products, pricelist) => { } const productVariantsResponseMap = (parent, products, pricelist) => { return products.map((product) => { - let price = product.price_f || 0 + let price = product.price_tier1_v2_f || 0 let priceDiscount = product.price_discount_f || 0 let discountPercentage = product.discount_f || 0 if (pricelist) { - const pricelistDiscount = product?.[`price_${pricelist}_f`] || false - const pricelistDiscountPerc = product?.[`discount_${pricelist}_f`] || false - - if (pricelistDiscount && pricelistDiscount > 0) priceDiscount = pricelistDiscount - if (pricelistDiscountPerc && pricelistDiscountPerc > 0) - discountPercentage = pricelistDiscountPerc + price = product?.[`price_${pricelist}_v2_f`] || 0 } if (product?.flashsale_id_i > 0) { |
