From cd51b64b48b0c898c6ff901c1bfa23c70cd9cf1a Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 12 Nov 2025 16:12:21 +0700 Subject: sementara --- src-migrate/modules/product-detail/components/AddToCart.tsx | 9 ++++++++- src-migrate/modules/product-detail/components/PriceAction.tsx | 1 + src-migrate/pages/shop/product/[slug].tsx | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/product-detail/components/AddToCart.tsx b/src-migrate/modules/product-detail/components/AddToCart.tsx index 147fd6d2..0dc39c1c 100644 --- a/src-migrate/modules/product-detail/components/AddToCart.tsx +++ b/src-migrate/modules/product-detail/components/AddToCart.tsx @@ -66,6 +66,8 @@ const AddToCart = ({ weight: '', isFlashSale: false, }); + const hasPrice = + !!product?.lowest_price && Number(product.lowest_price.price) > 0; useEffect(() => { const fetchData = async () => { @@ -183,6 +185,7 @@ const AddToCart = ({ colorScheme={btnConfig[source].colorScheme} variant={btnConfig[source].variant} className='w-full' + isDisabled={!hasPrice || status === 'loading'} > {btnConfig[source].text} @@ -194,6 +197,7 @@ const AddToCart = ({ colorScheme={btnConfig[source].colorScheme} variant={btnConfig[source].variant} className='w-full' + isDisabled={!hasPrice || status === 'loading'} > {btnConfig[source].text} @@ -208,7 +212,10 @@ const AddToCart = ({ {/* ===== MOBILE LAYOUT: konten scroll + footer fixed di dalam popup ===== */}
{/* area scroll */} -
+
{/* HEADER ITEM */}
diff --git a/src-migrate/modules/product-detail/components/PriceAction.tsx b/src-migrate/modules/product-detail/components/PriceAction.tsx index ffc9ba40..a329d2cc 100644 --- a/src-migrate/modules/product-detail/components/PriceAction.tsx +++ b/src-migrate/modules/product-detail/components/PriceAction.tsx @@ -37,6 +37,7 @@ const PriceAction = ({ product }: Props) => { } = useProductDetail(); const [qtyPickUp, setQtyPickUp] = useState(0); const { isDesktop, isMobile } = useDevice(); + useEffect(() => { setActive(selectedVariant); if (product.variants.length > 2 && product.variants[0].price.price === 0) { diff --git a/src-migrate/pages/shop/product/[slug].tsx b/src-migrate/pages/shop/product/[slug].tsx index 058e4832..8d6558b1 100644 --- a/src-migrate/pages/shop/product/[slug].tsx +++ b/src-migrate/pages/shop/product/[slug].tsx @@ -49,7 +49,7 @@ export const getServerSideProps: GetServerSideProps = async ( Array.isArray(product.variants) && product.variants.some((v) => (v?.price?.price ?? 0) > 0); - if (!hasValidVariant) return { notFound: true }; + // if (!hasValidVariant) return { notFound: true }; // bikin canonical path yang BERSIH dan KONSISTEN dari data produk, // bukan dari URL request user (jadi gak ikut ?utm_source, ?ref=, dsb) -- cgit v1.2.3 From 7cf105a01a814c5f76dd6b407df284a44026cabf Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 12 Nov 2025 17:14:37 +0700 Subject: done product detail --- .../product-detail/components/AddToQuotation.tsx | 20 ++++++- .../product-detail/components/PriceAction.tsx | 26 ++++++--- .../product-detail/components/ProductDetail.tsx | 67 +++++++++++++++------- 3 files changed, 80 insertions(+), 33 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/product-detail/components/AddToQuotation.tsx b/src-migrate/modules/product-detail/components/AddToQuotation.tsx index ebfcef32..3e811330 100644 --- a/src-migrate/modules/product-detail/components/AddToQuotation.tsx +++ b/src-migrate/modules/product-detail/components/AddToQuotation.tsx @@ -60,6 +60,8 @@ const AddToQuotation = ({ `fq=-manufacture_id_i:${product.manufacture?.id || 0}`, ].join('&'); const [addCartAlert, setAddCartAlert] = useState(false); + const hasPrice = + !!product?.lowest_price && Number(product.lowest_price.price) > 0; const handleButton = async () => { if (typeof auth !== 'object') { @@ -124,9 +126,10 @@ const AddToQuotation = ({ color={'red'} colorScheme='white' className='w-full border-2 p-2 gap-1 hover:bg-slate-100 flex items-center' + isDisabled={!hasPrice} > )} - {!!product.lowest_price && product.lowest_price.price === 0 && ( + {(!!product.lowest_price && product.lowest_price.price === 0) || + product.lowest_price.price < 0 ? ( + + Hubungi kami untuk dapatkan harga terbaik,{' '} + + klik disini + + + ) : ( Hubungi kami untuk dapatkan harga terbaik,{' '} { const validJsonString = stringVoucher.replace(/'/g, '"'); voucherPastiHemat = JSON.parse(validJsonString); } + const hasPrice = Number(product?.lowest_price?.price) > 0; return (
{ )} - {!!activePrice && activePrice.price === 0 && ( + {/* {!!activePrice && activePrice.price === 0 && ( Hubungi kami untuk dapatkan harga terbaik,{' '} { klik disini - )} + )} */}
@@ -165,27 +166,32 @@ const PriceAction = ({ product }: Props) => {
+ setQuantityInput(e.target.value)} - className={style['quantity-input']} + className={`${style['quantity-input']} disabled:bg-gray-100 disabled:text-gray-400`} + disabled={!hasPrice} /> + @@ -196,9 +202,11 @@ const PriceAction = ({ product }: Props) => { - Stock : {sla?.qty}{' '} + Stock : {hasPrice ? sla?.qty : 'Habis'}
@@ -219,9 +227,9 @@ const PriceAction = ({ product }: Props) => { )}
- + {/* * {qtyPickUp} barang bisa di pickup - + */} {/* ===== MOBILE: grid kiri-kanan, kanan hanya qty ===== */} diff --git a/src-migrate/modules/product-detail/components/ProductDetail.tsx b/src-migrate/modules/product-detail/components/ProductDetail.tsx index f32bb38e..c8c03300 100644 --- a/src-migrate/modules/product-detail/components/ProductDetail.tsx +++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx @@ -5,7 +5,12 @@ import { useRouter } from 'next/router'; import { useEffect, useRef, useState, UIEvent } from 'react'; import { Button } from '@chakra-ui/react'; -import { MessageCircleIcon, Share2Icon } from 'lucide-react'; +import { + AlertCircle, + AlertTriangle, + MessageCircleIcon, + Share2Icon, +} from 'lucide-react'; import { LazyLoadComponent } from 'react-lazy-load-image-component'; import useDevice from '@/core/hooks/useDevice'; @@ -23,7 +28,6 @@ import SimilarBottom from './SimilarBottom'; import SimilarSide from './SimilarSide'; import dynamic from 'next/dynamic'; - import { gtagProductDetail } from '@/core/utils/googleTag'; type Props = { @@ -31,7 +35,7 @@ type Props = { }; const RWebShare = dynamic( - () => import('react-web-share').then(m => m.RWebShare), + () => import('react-web-share').then((m) => m.RWebShare), { ssr: false } ); @@ -42,7 +46,9 @@ const ProductDetail = ({ product }: Props) => { const router = useRouter(); const [auth, setAuth] = useState(null); useEffect(() => { - try { setAuth(getAuth() ?? null); } catch { } + try { + setAuth(getAuth() ?? null); + } catch {} }, []); const canShare = @@ -87,7 +93,6 @@ const ProductDetail = ({ product }: Props) => { setSelectedVariant(selectedVariant); }, []); - const allImages = (() => { const arr: string[] = []; if (product?.image) arr.push(product.image); @@ -95,7 +100,6 @@ const ProductDetail = ({ product }: Props) => { Array.isArray(product?.image_carousel) && product.image_carousel.length ) { - const set = new Set(arr); for (const img of product.image_carousel) { if (!set.has(img)) { @@ -108,15 +112,14 @@ const ProductDetail = ({ product }: Props) => { })(); const [mainImage, setMainImage] = useState(allImages[0] || ''); + const hasPrice = Number(product?.lowest_price?.price) > 0; useEffect(() => { - if (!allImages.includes(mainImage)) { setMainImage(allImages[0] || ''); } }, [allImages]); - const sliderRef = useRef(null); const [currentIdx, setCurrentIdx] = useState(0); @@ -138,7 +141,6 @@ const ProductDetail = ({ product }: Props) => { setMainImage(allImages[i] || ''); }; - return ( <>
@@ -165,7 +167,6 @@ const ProductDetail = ({ product }: Props) => { > {allImages.length > 0 ? ( allImages.map((img, i) => ( -
{ | - +
+ +
| @@ -317,10 +335,17 @@ const ProductDetail = ({ product }: Props) => { data={{ text: 'Check out this product', title: `${product.name} - Indoteknik.com`, - url: (process.env.NEXT_PUBLIC_SELF_HOST || '') + (router?.asPath || '/'), + url: + (process.env.NEXT_PUBLIC_SELF_HOST || '') + + (router?.asPath || '/'), }} > - @@ -350,8 +375,6 @@ const ProductDetail = ({ product }: Props) => {
); - - }; export default ProductDetail; -- cgit v1.2.3 From 0eedef242e76673e6882ec11b87a9371d6ec5164 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 12 Nov 2025 17:22:46 +0700 Subject: mobile --- src-migrate/modules/product-detail/components/PriceAction.tsx | 7 +++++-- src-migrate/modules/product-detail/components/ProductDetail.tsx | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/product-detail/components/PriceAction.tsx b/src-migrate/modules/product-detail/components/PriceAction.tsx index 510dd6a9..d73ab5f6 100644 --- a/src-migrate/modules/product-detail/components/PriceAction.tsx +++ b/src-migrate/modules/product-detail/components/PriceAction.tsx @@ -264,11 +264,11 @@ const PriceAction = ({ product }: Props) => { )}
- {qtyPickUp > 0 && ( + {/* {qtyPickUp > 0 && (
* {qtyPickUp} barang bisa di pickup
- )} + )} */}
{/* Kanan: hanya qty, rata kanan */} @@ -283,6 +283,7 @@ const PriceAction = ({ product }: Props) => { ) } aria-label='Kurangi' + disabled={!hasPrice} > @@ -297,6 +298,7 @@ const PriceAction = ({ product }: Props) => { [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none' + disabled={!hasPrice} /> diff --git a/src-migrate/modules/product-detail/components/ProductDetail.tsx b/src-migrate/modules/product-detail/components/ProductDetail.tsx index c8c03300..76fa8298 100644 --- a/src-migrate/modules/product-detail/components/ProductDetail.tsx +++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx @@ -252,7 +252,7 @@ const ProductDetail = ({ product }: Props) => { {/* ===== Kolom kanan: info ===== */}
{!hasPrice && ( -
+
Date: Wed, 12 Nov 2025 17:56:28 +0700 Subject: fix label desktop and mobile --- .../product-detail/components/ProductDetail.tsx | 68 ++++++++++++++++------ 1 file changed, 50 insertions(+), 18 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/product-detail/components/ProductDetail.tsx b/src-migrate/modules/product-detail/components/ProductDetail.tsx index 76fa8298..354889e5 100644 --- a/src-migrate/modules/product-detail/components/ProductDetail.tsx +++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx @@ -143,6 +143,16 @@ const ProductDetail = ({ product }: Props) => { return ( <> + {/* WATERMARK OVERLAY jika produk tidak punya harga */} + {!hasPrice && ( +
+ Produk tidak tersedia +
+ )}
@@ -250,24 +260,46 @@ const ProductDetail = ({ product }: Props) => { {/* <<=== TUTUP kolom kiri */} {/* ===== Kolom kanan: info ===== */} -
- {!hasPrice && ( -
- -

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

-
- )} -
-

{product.name}

-
- -
-
+ {isDesktop && ( +
+ {!hasPrice && ( +
+ +

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

+
+ )} +
+

{product.name}

+
+ +
+
+ )} + {isMobile && ( +
+ {!hasPrice && ( +
+ +

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

+
+ )} +
+

{product.name}

+
+ +
+
+ )}
-- cgit v1.2.3 From d292f00640a5b0cf68019eedebcdbb87ecb27270 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 12 Nov 2025 18:18:03 +0700 Subject: watermark produk tidak tersedia --- .../modules/product-detail/components/ProductDetail.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/product-detail/components/ProductDetail.tsx b/src-migrate/modules/product-detail/components/ProductDetail.tsx index 354889e5..388d2248 100644 --- a/src-migrate/modules/product-detail/components/ProductDetail.tsx +++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx @@ -143,16 +143,16 @@ const ProductDetail = ({ product }: Props) => { return ( <> - {/* WATERMARK OVERLAY jika produk tidak punya harga */} - {!hasPrice && ( -
+ {isDesktop && !hasPrice && ( +
Produk tidak tersedia
)} +
@@ -293,7 +293,6 @@ const ProductDetail = ({ product }: Props) => {
)} -

{product.name}

-- cgit v1.2.3 From ff27a8752df545554fcee1beb8acbb24011a040b Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 12 Nov 2025 18:33:30 +0700 Subject: mobile watermark --- src-migrate/modules/product-detail/components/ProductDetail.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src-migrate') diff --git a/src-migrate/modules/product-detail/components/ProductDetail.tsx b/src-migrate/modules/product-detail/components/ProductDetail.tsx index 388d2248..48270dee 100644 --- a/src-migrate/modules/product-detail/components/ProductDetail.tsx +++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx @@ -152,6 +152,15 @@ const ProductDetail = ({ product }: Props) => { />
)} + {isMobile && !hasPrice && ( +
+ Produk tidak tersedia +
+ )}
-- cgit v1.2.3 From 8ed66318c1e94d4c744984f2aab25ff993d5de4d Mon Sep 17 00:00:00 2001 From: Miqdad Date: Thu, 13 Nov 2025 15:59:08 +0700 Subject: cr watermark --- .../product-detail/components/ProductDetail.tsx | 41 ++++++++++++---------- 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'src-migrate') diff --git a/src-migrate/modules/product-detail/components/ProductDetail.tsx b/src-migrate/modules/product-detail/components/ProductDetail.tsx index 48270dee..e4ba2b2f 100644 --- a/src-migrate/modules/product-detail/components/ProductDetail.tsx +++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx @@ -143,24 +143,29 @@ const ProductDetail = ({ product }: Props) => { return ( <> - {isDesktop && !hasPrice && ( -
- Produk tidak tersedia -
- )} - {isMobile && !hasPrice && ( -
- Produk tidak tersedia -
- )} +
+ {isDesktop && !hasPrice && ( +
+ Produk tidak tersedia +
+ )} +
+ +
+ {isMobile && !hasPrice && ( +
+ Produk tidak tersedia +
+ )} +
-- cgit v1.2.3