From d2fb20c30fa3440369807c05d01897eb19483f4c Mon Sep 17 00:00:00 2001 From: FIN-IT_AndriFP Date: Mon, 8 Dec 2025 14:55:49 +0700 Subject: (andri) modal compare without data --- .../product-detail/components/AddToQuotation.tsx | 93 +++++++++++++-------- .../product-detail/components/PriceAction.tsx | 38 +++------ .../components/ProductComparisonModal.tsx | 46 +++++++++++ .../product-detail/components/ProductDetail.tsx | 95 ++++++++++++++++++---- 4 files changed, 196 insertions(+), 76 deletions(-) create mode 100644 src-migrate/modules/product-detail/components/ProductComparisonModal.tsx diff --git a/src-migrate/modules/product-detail/components/AddToQuotation.tsx b/src-migrate/modules/product-detail/components/AddToQuotation.tsx index 3e811330..0ea88830 100644 --- a/src-migrate/modules/product-detail/components/AddToQuotation.tsx +++ b/src-migrate/modules/product-detail/components/AddToQuotation.tsx @@ -1,7 +1,8 @@ import BottomPopup from '@/core/components/elements/Popup/BottomPopup'; import style from '../styles/price-action.module.css'; -import { Button, Link, useToast } from '@chakra-ui/react'; -import { ArrowDownTrayIcon } from '@heroicons/react/24/outline'; +import { Button, Link, useToast, Icon } from '@chakra-ui/react'; +// Pastikan icon ini ada (atau ganti dengan text sementara jika error) +import { ScaleIcon } from '@heroicons/react/24/outline'; import product from 'next-seo/lib/jsonld/product'; import { useRouter } from 'next/router'; import { useEffect, useState } from 'react'; @@ -17,12 +18,15 @@ import { createSlug } from '~/libs/slug'; import formatCurrency from '~/libs/formatCurrency'; import { useProductDetail } from '../stores/useProductDetail'; import useDevice from '@/core/hooks/useDevice'; +import DesktopView from '@/core/components/views/DesktopView'; +import MobileView from '@/core/components/views/MobileView'; type Props = { variantId: number | null; quantity?: number; source?: 'buy' | 'add_to_cart'; products: IProductDetail; + onCompare?: () => void; // <--- 1. Tambah Props }; type Status = 'idle' | 'loading' | 'success'; @@ -32,6 +36,7 @@ const AddToQuotation = ({ quantity = 1, source = 'add_to_cart', products, + onCompare // <--- 2. Tangkap Props }: Props) => { const auth = getAuth(); const router = useRouter(); @@ -106,37 +111,59 @@ const AddToQuotation = ({ }, 3000); }, [status]); - const btnConfig = { - add_to_cart: { - colorScheme: 'red', - variant: 'outline', - text: 'Keranjang', - }, - buy: { - colorScheme: 'red', - variant: 'solid', - text: 'Beli', - }, - }; - return ( -
- +
{/* Ganti div biasa jadi Flex Column gap 3 */} + + {/* 3. TAMPILAN DESKTOP: GRID 2 KOLOM (Bandingkan & Penawaran) */} + +
+ {/* Tombol Kiri: Bandingkan */} + + + {/* Tombol Kanan: Penawaran (Link WA) */} + +
+
+ + {/* TAMPILAN MOBILE (Tetap seperti semula - hanya icon Penawaran) */} + + + + void; }; const PPN: number = process.env.NEXT_PUBLIC_PPN ? parseFloat(process.env.NEXT_PUBLIC_PPN) : 0; -const PriceAction = ({ product }: Props) => { + +const PriceAction = ({ product, onCompare }: Props) => { const { activePrice, setActive, @@ -146,19 +148,6 @@ const PriceAction = ({ product }: Props) => { )} - {/* {!!activePrice && activePrice.price === 0 && ( - - Hubungi kami untuk dapatkan harga terbaik,{' '} - - klik disini - - - )} */} -
@@ -227,9 +216,6 @@ const PriceAction = ({ product }: Props) => { )}
- {/* - * {qtyPickUp} barang bisa di pickup - */}
{/* ===== MOBILE: grid kiri-kanan, kanan hanya qty ===== */} @@ -263,12 +249,6 @@ const PriceAction = ({ product }: Props) => { )}
- - {/* {qtyPickUp > 0 && ( -
- * {qtyPickUp} barang bisa di pickup -
- )} */}
{/* Kanan: hanya qty, rata kanan */} @@ -295,9 +275,9 @@ const PriceAction = ({ product }: Props) => { value={quantityInput} onChange={(e) => setQuantityInput(e.target.value)} className='h-11 md:h-12 w-16 md:w-20 text-center text-lg md:text-xl outline-none border-x - [appearance:textfield] - [&::-webkit-outer-spin-button]:appearance-none - [&::-webkit-inner-spin-button]:appearance-none' + [appearance:textfield] + [&::-webkit-outer-spin-button]:appearance-none + [&::-webkit-inner-spin-button]:appearance-none' disabled={!hasPrice} /> @@ -335,11 +315,13 @@ const PriceAction = ({ product }: Props) => { )}
+ {/* 2. TERUSKAN onCompare KE SINI */}
@@ -376,4 +358,4 @@ const PriceAction = ({ product }: Props) => { ); }; -export default PriceAction; +export default PriceAction; \ No newline at end of file diff --git a/src-migrate/modules/product-detail/components/ProductComparisonModal.tsx b/src-migrate/modules/product-detail/components/ProductComparisonModal.tsx new file mode 100644 index 00000000..aa4388a6 --- /dev/null +++ b/src-migrate/modules/product-detail/components/ProductComparisonModal.tsx @@ -0,0 +1,46 @@ +import { + Modal, + ModalOverlay, + ModalContent, + ModalHeader, + ModalBody, + ModalCloseButton, + Button, + ModalFooter, + Center, + Text, + Box +} from '@chakra-ui/react'; + +type Props = { + isOpen: boolean; + onClose: () => void; +}; + +const ProductComparisonModal = ({ isOpen, onClose }: Props) => { + return ( + + + + Perbandingan Produk + + + +
+ Test + Modal Berhasil Terbuka! + + Fitur komparasi produk akan muncul di sini nanti. + +
+
+ + + + +
+
+ ); +}; + +export default ProductComparisonModal; \ No newline at end of file diff --git a/src-migrate/modules/product-detail/components/ProductDetail.tsx b/src-migrate/modules/product-detail/components/ProductDetail.tsx index fab5ecf3..f06f958a 100644 --- a/src-migrate/modules/product-detail/components/ProductDetail.tsx +++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx @@ -49,6 +49,9 @@ import SimilarBottom from './SimilarBottom'; import SimilarSide from './SimilarSide'; import dynamic from 'next/dynamic'; +// 1. IMPORT MODAL (Baru) +import ProductComparisonModal from './ProductComparisonModal'; + import { gtagProductDetail } from '@/core/utils/googleTag'; type Props = { @@ -74,6 +77,9 @@ const ProductDetail = ({ product }: Props) => { const [loadingSpecs, setLoadingSpecs] = useState(false); + // 2. STATE MODAL COMPARE (Baru) + const [isCompareOpen, setCompareOpen] = useState(false); + useEffect(() => { try { setAuth(getAuth() ?? null); @@ -322,6 +328,13 @@ const ProductDetail = ({ product }: Props) => { return ( <> + {/* 3. MODAL POPUP DIRENDER DISINI */} + {/* Render di luar layout utama agar tidak tertutup elemen lain */} + setCompareOpen(false)} + /> +
{isDesktop && !hasPrice && (
@@ -406,9 +419,9 @@ const ProductDetail = ({ product }: Props) => { size={18} className='text-red-600 shrink-0 mx-2' /> -
+

Maaf untuk saat ini Produk yang anda cari tidak tersedia -

+
)}
@@ -426,9 +439,9 @@ const ProductDetail = ({ product }: Props) => { size={18} className='text-red-600 shrink-0 mx-2' /> -
+

Maaf untuk saat ini Produk yang anda cari tidak tersedia -

+
)}

{product.name}

@@ -448,7 +461,10 @@ const ProductDetail = ({ product }: Props) => {
{!!activeVariantId && !isApproval && ( - + )}
@@ -457,25 +473,49 @@ const ProductDetail = ({ product }: Props) => {
- Deskripsi - Spesifikasi - Detail Lainnya + + Deskripsi + + + Spesifikasi + + + Detail Lainnya + {/* DESKRIPSI */}
-

' ? '

Lorem ipsum dolor sit amet.

' : product.description, }} /> +

' + ? '

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

' + : product.description, + }} + />
- {/* SPESIFIKASI (LOGIKA GROUPING + RATA TENGAH) */} + {/* SPESIFIKASI (MATRIKS & SPLIT PIPA) */} {loadingSpecs ? (
) : specsMatrix.length > 0 ? ( + // Cek Single vs Multi Variant (() => { const isSingleVariant = product.variants.length === 1; const globalAlign = isSingleVariant ? "left" : "center"; @@ -484,11 +524,27 @@ const ProductDetail = ({ product }: Props) => { - + {product.variants.map(v => ( - ))} @@ -563,13 +619,22 @@ const ProductDetail = ({ product }: Props) => { - {/* ... (Bagian Sidebar & Bottom SAMA) ... */} {isDesktop && (
- + {/* 4. INTEGRASI: PASSING HANDLER MODAL KE PRICE ACTION */} + setCompareOpen(true)} + /> +
- {/* ... Buttons ... */} + + | +
+ | + {canShare && ()}
+
Produk Serupa
-- cgit v1.2.3
+ Spesifikasi + {isSingleVariant ? 'Detail' : (v.attributes && v.attributes.length > 0 ? v.attributes.join(' - ') : v.code)}