import Image from '@/core/components/elements/Image/Image' import Link from '@/core/components/elements/Link/Link' import currencyFormat from '@/core/utils/currencyFormat' import { createSlug } from '@/core/utils/slug' import whatsappUrl from '@/core/utils/whatsappUrl' import ImageNext from 'next/image' import { useRouter } from 'next/router' const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { const router = useRouter() const callForPriceWhatsapp = whatsappUrl('product', { name: product.name, url: createSlug('/shop/product/', product.name, product.id, true) }) if (variant == 'vertical') { return (
{product?.name} {router.pathname != '/' && product?.flashSale?.id > 0 && (
{product?.lowestPrice.discountPercentage}%
{product?.flashSale?.tag != 'false' || product?.flashSale?.tag ? product?.flashSale?.tag : 'FLASH SALE'}
)} {product.variantTotal > 1 && (
{product.variantTotal} Varian
)}
{product?.manufacture?.name ? ( {product.manufacture.name} ) : (
-
)} {product?.name} {product?.flashSale?.id > 0 ? ( <> {product?.lowestPrice.discountPercentage > 0 && (
{currencyFormat(product.lowestPrice.price)}
{product?.lowestPrice.discountPercentage}%
)}
{product?.lowestPrice.priceDiscount > 0 ? ( currencyFormat(product?.lowestPrice.priceDiscount) ) : ( Call for price )}
) : (
{product?.lowestPrice.price > 0 ? ( <> {currencyFormat(product?.lowestPrice.price)}
Incl {currencyFormat(product.lowestPrice.price * process.env.NEXT_PUBLIC_PPN )}
) : ( Call for price )}
)} {product?.stockTotal > 0 && (
Ready Stock
{product?.stockTotal > 5 ? '> 5' : '< 5'}
)}
) } if (variant == 'horizontal') { return (
{product?.name} {product.variantTotal > 1 && (
{product.variantTotal} Varian
)}
{product.flashSale.id > 0 && (
{' '} {product?.flashSale?.tag != 'false' || product?.flashSale?.tag ? product?.flashSale?.tag : 'FLASH SALE'}
)} {product?.manufacture?.name ? ( {product.manufacture.name} ) : (
-
)} {product?.name} {product?.lowestPrice?.discountPercentage > 0 && (
{product?.lowestPrice?.discountPercentage}%
{currencyFormat(product?.lowestPrice?.price)}
)}
{product?.lowestPrice?.priceDiscount > 0 ? ( currencyFormat(product?.lowestPrice?.priceDiscount) ) : ( Call for price )}
{product?.stockTotal > 0 && (
Ready Stock
{product?.stockTotal > 5 ? '> 5' : '< 5'}
)}
) } } export default ProductCard