From 44862321cf5974c07d13a00c72f2b53567f98a47 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Tue, 14 Oct 2025 18:39:36 +0700 Subject: product card change renca --- src/lib/product/components/ProductCard.jsx | 610 +++++++++++++++++++++-------- 1 file changed, 453 insertions(+), 157 deletions(-) diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index f4f5882e..d5188d5c 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -11,6 +11,10 @@ import { createSlug } from '@/core/utils/slug'; import whatsappUrl from '@/core/utils/whatsappUrl'; import useUtmSource from '~/hooks/useUtmSource'; import useDevice from '@/core/hooks/useDevice'; +import { BadgePercent, Tag } from 'lucide-react'; +import { TicketIcon } from '@heroicons/react/24/outline'; +import DesktopView from '@/core/components/views/DesktopView'; +import MobileView from '@/core/components/views/MobileView'; const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { const router = useRouter(); @@ -73,186 +77,470 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { if (variant == 'vertical') { return ( -
- -
- {product?.name} -
-
- {product?.isSni && ( - + <> + +
+ +
+ {product?.name} +
+
+ {product?.isSni && ( + + )} +
+
+ {product?.isTkdn && ( + + )} +
+
+
+ + {router.pathname != '/' && product?.flashSale?.id > 0 && ( +
+
+ +
+
+
+
+ + {Math.floor(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?.isInBu && ( + + pickup now + )}
-
- {product?.isTkdn && ( - + + {product?.name} + + {product?.flashSale?.id > 0 && + product?.lowestPrice.discountPercentage > 0 ? ( + <> +
+
+ {currencyFormat(product.lowestPrice.price)} +
+
+ {Math.floor(product?.lowestPrice.discountPercentage)}% +
+
+
+ {product?.lowestPrice.priceDiscount > 0 ? ( + currencyFormat(product?.lowestPrice.priceDiscount) + ) : ( + + Call for Inquiry + + )} +
+ + ) : ( +
+ {product?.lowestPrice.price > 0 ? ( + <> + {currencyFormat(product?.lowestPrice.price)} +
+ Inc. PPN:{' '} + {currencyFormat( + product.lowestPrice.price * + process.env.NEXT_PUBLIC_PPN + )} +
+ + ) : ( + + Call for Inquiry + + )} +
+ )} + {discount > 0 && product?.flashSale?.id < 1 && ( +
+
+ Voucher : {currencyFormat(discount)} +
+
+ )} + +
+ {product?.stockTotal > 0 && ( +
Ready Stock
+ )} + {/*
{product?.stockTotal > 5 ? '> 5' : '< 5'}
*/} + {product?.qtySold > 0 && ( +
+ {sellingProductFormat(product?.qtySold) + ' Terjual'} +
)}
+ - {router.pathname != '/' && product?.flashSale?.id > 0 && ( -
-
- +
+ +
+ {product?.name} +
+
+ {product?.isSni && ( + + )} +
+
+ {product?.isTkdn && ( + + )} +
+
-
-
-
- - {Math.floor(product?.lowestPrice.discountPercentage)}% - + {/* BADGE DISKON KIRI-ATAS */} + {(product?.lowestPrice?.discountPercentage ?? 0) > 0 && ( +
+
+ {Math.floor(product.lowestPrice.discountPercentage)}%
-
+
+ )} + + {router.pathname != '/' && product?.flashSale?.id > 0 && ( +
+
- - {product?.flashSale?.tag != 'false' || - product?.flashSale?.tag - ? product?.flashSale?.tag - : 'FLASH SALE'} - +
+
+ {/* Old */} + {/*
+
+ + {Math.floor(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?.isInBu && ( - - pickup now - - )} -
- - {product?.name} - - {product?.flashSale?.id > 0 && - product?.lowestPrice.discountPercentage > 0 ? ( - <> -
-
- {currencyFormat(product.lowestPrice.price)} -
-
- {Math.floor(product?.lowestPrice.discountPercentage)}% + )} + {product.variantTotal > 1 && ( +
+ {product.variantTotal} Varian
-
-
- {product?.lowestPrice.priceDiscount > 0 ? ( - currencyFormat(product?.lowestPrice.priceDiscount) + )} + +
+
+ {product?.manufacture?.name ? ( + + {product.manufacture.name} + ) : ( - -
+ )} + {/* PICK UP NOW badge (kanan-atas gambar) */} + {product?.isInBu && ( + - Call for Inquiry - + + PICK UP NOW + + )} + + {/* Old */} + {/* {product?.isInBu && ( + + pickup now + + )} */}
- - ) : ( -
- {product?.lowestPrice.price > 0 ? ( - <> - {currencyFormat(product?.lowestPrice.price)} -
- Inc. PPN:{' '} - {currencyFormat( - product.lowestPrice.price * process.env.NEXT_PUBLIC_PPN - )} + + {product?.name} + + {product?.flashSale?.id > 0 && + product?.lowestPrice.discountPercentage > 0 ? ( +
+
+ {/* harga sekarang (merah) */} + + {product?.lowestPrice.priceDiscount > 0 ? ( + currencyFormat(product?.lowestPrice.price) + ) : ( + + Call for Inquiry + + )} + + + {/* harga lama (abu, dicoret) */} + + {currencyFormat(product.lowestPrice.price)} +
- +
) : ( - - Call for Inquiry - + // === BLOK ELSE PUNYA KAMU, TIDAK DIUBAH === +
+ {product?.lowestPrice.price > 0 ? ( + <> + {currencyFormat(product?.lowestPrice.priceDiscount)} +
+ Include PPN:{' '} + {currencyFormat( + product.lowestPrice.price * + process.env.NEXT_PUBLIC_PPN + )} +
+ + ) : ( + + Call for Inquiry + + )} +
)} -
- )} - {discount > 0 && product?.flashSale?.id < 1 && ( -
-
- Voucher : {currencyFormat(discount)} -
-
- )} -
- {product?.stockTotal > 0 && ( -
Ready Stock
- )} - {/*
{product?.stockTotal > 5 ? '> 5' : '< 5'}
*/} - {product?.qtySold > 0 && ( -
- {sellingProductFormat(product?.qtySold) + ' Terjual'} -
- )} + {discount > 0 && (product?.flashSale?.id ?? 0) < 1 && ( +
+
+ {/* Label polos (bukan dalam kotak) */} + Pakai Voucher + + {/* Chip: ikon + nominal */} + + + + + {currencyFormat(discount)} + + +
+
+ )} + + {(product?.stockTotal > 0 || product?.qtySold > 0) && ( +
+ {product?.stockTotal > 0 && ( +
Ready Stock
+ )} + + {product?.qtySold > 0 && ( +
+ {sellingProductFormat(product?.qtySold)} Terjual +
+ )} +
+ )} + + {/* Old */} + {/*
+ {product?.stockTotal > 0 && ( +
Ready Stock
+ )} +
{product?.stockTotal > 5 ? '> 5' : '< 5'}
+ {product?.qtySold > 0 && ( +
+ {sellingProductFormat(product?.qtySold) + ' Terjual'} +
+ )} +
*/} +
-
-
+ + ); } @@ -260,7 +548,11 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { return (
- +
{ )} {product?.manufacture?.name ? (
- + {product.manufacture.name} {/* {product?.is_in_bu && ( -- cgit v1.2.3