From d793056d1645c221d02fb821e34ab2c435c387d0 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Thu, 13 Nov 2025 16:20:23 +0700 Subject: product variant --- .../components/Product/ProductDesktopVariant.jsx | 151 ++++++++++++--------- 1 file changed, 88 insertions(+), 63 deletions(-) (limited to 'src/lib/product/components/Product/ProductDesktopVariant.jsx') diff --git a/src/lib/product/components/Product/ProductDesktopVariant.jsx b/src/lib/product/components/Product/ProductDesktopVariant.jsx index 44ae04bd..6b4ab1e1 100644 --- a/src/lib/product/components/Product/ProductDesktopVariant.jsx +++ b/src/lib/product/components/Product/ProductDesktopVariant.jsx @@ -1,3 +1,4 @@ +import { AlertTriangle } from 'lucide-react'; import { Box, Button, Skeleton, Tooltip } from '@chakra-ui/react'; import { HeartIcon } from '@heroicons/react/24/outline'; import { Info, MessageCircleIcon, Share2Icon } from 'lucide-react'; @@ -249,6 +250,7 @@ const ProductDesktopVariant = ({ }); router.push('/shop/quotation?source=buy'); }; + const hasPrice = Number(product?.price?.price) > 0; const variantSectionRef = useRef(null); const goToVariantSection = () => { @@ -314,6 +316,17 @@ const ProductDesktopVariant = ({ return ( +
+ {!hasPrice && ( +
+ Produk tidak tersedia +
+ )} +
@@ -326,9 +339,21 @@ const ProductDesktopVariant = ({
+ {!hasPrice && ( +
+ +

+ Maaf untuk saat ini Produk yang anda cari tidak tersedia +

+
+ )}

{product?.name}

+
Item Code
@@ -430,73 +455,55 @@ const ProductDesktopVariant = ({
- {product?.isFlashsale > 0 && - product?.price?.discountPercentage > 0 ? ( + {product?.price?.price > 0 && ( <> -
-
- {product?.price?.discountPercentage}% -
-
- {currencyFormat(product?.price?.price)} -
-
- {currencyFormat(product?.price?.priceDiscount)} -
-
-
- Termasuk PPN:{' '} - {currencyFormat( - product?.price?.priceDiscount * process.env.NEXT_PUBLIC_PPN - )} -
- - ) : ( -

- {product?.price?.price > 0 ? ( + {product?.isFlashsale > 0 && + product?.price?.discountPercentage > 0 ? ( <> - {currencyFormat(product?.price?.price)} +
+
+ {product?.price?.discountPercentage}% +
+
+ {currencyFormat(product?.price?.price)} +
+
+ {currencyFormat(product?.price?.priceDiscount)} +
+
Termasuk PPN:{' '} {currencyFormat( - product?.price?.price * process.env.NEXT_PUBLIC_PPN + product?.price?.priceDiscount * + process.env.NEXT_PUBLIC_PPN )}
) : ( - - Hubungi kami untuk dapatkan harga terbaik,  - - klik disini - - +

+ {currencyFormat(product?.price?.price)} +
+ Termasuk PPN:{' '} + {currencyFormat( + product?.price?.price * process.env.NEXT_PUBLIC_PPN + )} +
+

)} - + )} +
@@ -518,43 +525,40 @@ const ProductDesktopVariant = ({ if (['e', 'E', '+', '-', '.'].includes(e.key)) e.preventDefault(); }} - className='w-24 h-10 text-center border border-gray-300 rounded focus:outline-none' + className='w-24 h-10 text-center border border-gray-300 rounded focus:outline-none disabled:bg-gray-100 disabled:text-gray-400' + disabled={!hasPrice} />
- {/* - Stock : {product?.sla?.qty}{' '} - */} - - Stock : {fakeStock}{' '} + Stock : {hasPrice ? fakeStock : 'Habis'}
+
- {qtyPickUp > 0 && ( + {qtyPickUp > 0 && hasPrice && (
- {qtyPickUp > 0 && ( + {/* {qtyPickUp > 0 && ( <>
* {qtyPickUp} barang bisa di pickup
- )} + )} */}
@@ -586,6 +593,9 @@ const ProductDesktopVariant = ({ onClick={() => handleBuy(product.id)} className='w-full' colorScheme='red' + isDisabled={ + !product?.price?.price || product?.price?.price <= 0 + } > Beli @@ -595,6 +605,7 @@ const ProductDesktopVariant = ({ color={'red'} colorScheme='white' className='w-full border-2 p-2 gap-1 mt-2 hover:bg-slate-100 flex items-center' + isDisabled={!product?.price?.price || product?.price?.price <= 0} > + {/* Watermark jika produk nonaktif */} + {/* {(!product?.price?.price || product?.price?.price <= 0) && ( +
+ + NONAKTIF + +
+ )} */}
{product.name} -- cgit v1.2.3