From 629133beeb7f5668b63db61e415cf844d513cde7 Mon Sep 17 00:00:00 2001 From: FIN-IT_AndriFP Date: Thu, 27 Nov 2025 14:30:30 +0700 Subject: (andri) view from magento --- .../product-detail/components/Information.tsx | 114 ++++++++++++------ .../product-detail/components/ProductDetail.tsx | 127 +++++++++++++++++---- 2 files changed, 185 insertions(+), 56 deletions(-) (limited to 'src-migrate/modules') diff --git a/src-migrate/modules/product-detail/components/Information.tsx b/src-migrate/modules/product-detail/components/Information.tsx index a7a58cbc..b7d3401e 100644 --- a/src-migrate/modules/product-detail/components/Information.tsx +++ b/src-migrate/modules/product-detail/components/Information.tsx @@ -11,12 +11,11 @@ import Link from 'next/link'; import { useEffect, useRef, useState } from 'react'; import currencyFormat from '@/core/utils/currencyFormat'; -import { InputGroup, InputRightElement, Spinner } from '@chakra-ui/react'; +import { InputGroup, InputRightElement, SimpleGrid, Flex, Text, Box } from '@chakra-ui/react'; import { ChevronDownIcon } from '@heroicons/react/24/outline'; import Image from 'next/image'; import { formatToShortText } from '~/libs/formatNumber'; import { createSlug } from '~/libs/slug'; -import { getVariantSLA } from '~/services/productVariant'; import { IProductDetail } from '~/types/product'; import { useProductDetail } from '../stores/useProductDetail'; import useVariant from '../hook/useVariant'; @@ -30,7 +29,7 @@ type Props = { }; const Information = ({ product }: Props) => { - const { selectedVariant, setSelectedVariant, setSla, setActive, sla } = + const { selectedVariant, setSelectedVariant, setSla, sla } = useProductDetail(); const [inputValue, setInputValue] = useState( @@ -45,15 +44,6 @@ const Information = ({ product }: Props) => { const variantId = selectedVariant?.id; const { slaVariant, isLoading } = useVariant({ variantId }); - // let variantOptions = product?.variants; - - // const querySLA = useQuery({ - // queryKey: ['variant-sla', selectedVariant?.id], - // queryFn: () => getVariantSLA(selectedVariant?.id), - // enabled: !!selectedVariant?.id, - // }); - // const sla = querySLA?.data; - useEffect(() => { if (selectedVariant) { setInputValue( @@ -66,14 +56,13 @@ const Information = ({ product }: Props) => { }, [selectedVariant]); useEffect(() => { - if (isLoading){ + if (isLoading) { setSla(null); } if (slaVariant) { setSla(slaVariant); } - }, [slaVariant, isLoading]); - + }, [slaVariant, isLoading, setSla]); const handleOnChange = (vals: any) => { setDisableFilter(true); @@ -98,6 +87,15 @@ const Information = ({ product }: Props) => { setInputValue(e.target.value); }; + // STYLE CUSTOM UNTUK BARIS (Item Code, dll) + const rowStyle = { + backgroundColor: '#ffffff', + fontSize: '13px', + borderBottom: '1px dashed #e2e8f0', + padding: '8px 0', + marginBottom: '0px' + }; + return (
@@ -183,12 +181,15 @@ const Information = ({ product }: Props) => {
-
-
Item Code
+ {/* ITEM CODE */} +
+
Item Code
{selectedVariant?.code}
-
-
Manufacture
+ + {/* MANUFACTURE */} +
+
Manufacture
{!!product.manufacture.name ? ( { )}
-
-
Berat Barang
+ + {/* BERAT BARANG */} +
+
Berat Barang
{selectedVariant?.weight > 0 ? `${selectedVariant?.weight} Kg` : '-'}
-
-
Terjual
+ + {/* TERJUAL */} +
+
Terjual
{product.qty_sold > 0 ? formatToShortText(product.qty_sold) : '-'}
-
-
Persiapan Barang
- {isLoading && ( -
- -
- )} - {!isLoading &&
{sla?.sla_date}
} + + {/* === DETAIL INFORMASI PRODUK (Updated Layout) === */} +
+

Detail Informasi Produk

+ + {/* Perubahan: Spacing diperbesar menjadi 10 agar estimasi bergeser ke kanan */} + + {/* 1. Distributor Resmi */} + + Distributor Resmi + + Distributor Resmi + Jaminan Produk Asli + + + + {/* 2. Estimasi Penyiapan */} + + Estimasi Penyiapan + + Estimasi Penyiapan + {isLoading ? ( + + ) : ( + + {sla?.sla_date || '3 - 7 Hari'} + + )} + + + + {/* 3. Garansi Produk */} + + Garansi Produk + + Garansi Produk + 24 Bulan + + +
+
); }; -export default Information; +export default Information; \ 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 e4ba2b2f..1bacd2e2 100644 --- a/src-migrate/modules/product-detail/components/ProductDetail.tsx +++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx @@ -4,9 +4,22 @@ import Link from 'next/link'; import { useRouter } from 'next/router'; import { useEffect, useRef, useState, UIEvent } from 'react'; -import { Button } from '@chakra-ui/react'; +// Import komponen Chakra UI yang dibutuhkan +import { + Button, + Tabs, + TabList, + TabPanels, + Tab, + TabPanel, + Table, + Tbody, + Tr, + Td, + Box +} from '@chakra-ui/react'; + import { - AlertCircle, AlertTriangle, MessageCircleIcon, Share2Icon, @@ -62,7 +75,6 @@ const ProductDetail = ({ product }: Props) => { setIsApproval, isApproval, setSelectedVariant, - setSla, } = useProductDetail(); useEffect(() => { @@ -136,11 +148,15 @@ const ProductDetail = ({ product }: Props) => { const scrollToIndex = (i: number) => { const el = sliderRef.current; if (!el) return; - el.scrollTo({ left: i * el.clientWidth, behavior: 'smooth' }); + const elRef = sliderRef.current; + elRef.scrollTo({ left: i * elRef.clientWidth, behavior: 'smooth' }); setCurrentIdx(i); setMainImage(allImages[i] || ''); }; + console.log('detail product render'); + console.log('product: ', product); + return ( <>
@@ -195,7 +211,6 @@ const ProductDetail = ({ product }: Props) => { key={i} className='w-full flex-shrink-0 snap-center flex justify-center items-center' > - {/* gambar diperkecil */} {`Gambar { )}
- {/* Dots indicator */} {allImages.length > 1 && (
{allImages.map((_, i) => ( @@ -238,8 +252,6 @@ const ProductDetail = ({ product }: Props) => { <> {/* === DESKTOP: Tetap seperti sebelumnya === */} - - {/* Carousel horizontal (thumbnail) – hanya desktop */} {allImages.length > 0 && (
@@ -271,7 +283,6 @@ const ProductDetail = ({ product }: Props) => { )}
- {/* <<=== TUTUP kolom kiri */} {/* ===== Kolom kanan: info ===== */} {isDesktop && ( @@ -332,21 +343,89 @@ const ProductDetail = ({ product }: Props) => {
+ {/* === SECTION TABS: DESKRIPSI & SPESIFIKASI === */}
-

Informasi Produk

-
-
-

' - ? 'Belum ada deskripsi' - : product.description, - }} - /> -
+ + {/* Header Tabs */} + + + Deskripsi + + + Spesifikasi + + + Detail Lainnya + + + + + {/* PANEL 1: DESKRIPSI */} + +
+

' + ? '

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

' + : product.description, + }} + /> +
+ + + {/* PANEL 2: SPESIFIKASI (Sesuai Gambar) */} + +

Informasi tambahan belum tersedia.

+
+ + {/* PANEL 3: DETAIL LAINNYA */} + +

Informasi tambahan belum tersedia.

+
+ + +
@@ -422,4 +501,4 @@ const ProductDetail = ({ product }: Props) => { ); }; -export default ProductDetail; +export default ProductDetail; \ No newline at end of file -- cgit v1.2.3