summaryrefslogtreecommitdiff
path: root/src-migrate/modules
diff options
context:
space:
mode:
authorIndoteknik . <andrifebriyadiputra@gmail.com>2025-05-26 12:37:08 +0700
committerIndoteknik . <andrifebriyadiputra@gmail.com>2025-05-26 12:37:08 +0700
commit2102158d77211991673aa7ed7cfacda69cceda2e (patch)
treec788fe583c25d172df93841f403389d01d9198dd /src-migrate/modules
parentca05a70e98e9066882de6394ffbd89db7af2cb9d (diff)
parent4ef92b4d9fea4fdd636d62194514b33ed3b3c387 (diff)
(andri) resolve conflict
Diffstat (limited to 'src-migrate/modules')
-rw-r--r--src-migrate/modules/popup-information/index.tsx6
-rw-r--r--src-migrate/modules/product-detail/components/ProductDetail.tsx44
-rw-r--r--src-migrate/modules/promo/components/Voucher.tsx1
3 files changed, 47 insertions, 4 deletions
diff --git a/src-migrate/modules/popup-information/index.tsx b/src-migrate/modules/popup-information/index.tsx
index d50711cc..cae50abf 100644
--- a/src-migrate/modules/popup-information/index.tsx
+++ b/src-migrate/modules/popup-information/index.tsx
@@ -15,7 +15,6 @@ const PagePopupInformation = () => {
const [data, setData] = useState<any>(null);
const [loading, setLoading] = useState(true);
-
useEffect(() => {
const getData = async () => {
const res = await fetch(`/api/hero-banner?type=popup-banner`);
@@ -44,7 +43,10 @@ const PagePopupInformation = () => {
className='w-[350px] md:w-[530px]'
onClick={() => setActive(false)}
>
- <Link href={data[0].url === false ? '/' :data[0].url} aria-label='popup'>
+ <Link
+ href={data[0].url === false ? '/' : data[0].url}
+ aria-label='popup'
+ >
<Image
src={data[0]?.image}
alt={data[0]?.name}
diff --git a/src-migrate/modules/product-detail/components/ProductDetail.tsx b/src-migrate/modules/product-detail/components/ProductDetail.tsx
index 1581f33d..192e1dc3 100644
--- a/src-migrate/modules/product-detail/components/ProductDetail.tsx
+++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx
@@ -2,7 +2,7 @@ import style from '../styles/product-detail.module.css';
import Link from 'next/link';
import { useRouter } from 'next/router';
-import { useEffect } from 'react';
+import { useEffect, useState } from 'react';
import { Button } from '@chakra-ui/react';
import { MessageCircleIcon, Share2Icon } from 'lucide-react';
@@ -74,6 +74,16 @@ const ProductDetail = ({ product }: Props) => {
// setSelectedVariant(product?.variants[0])
}, []);
+ // Gabungkan semua gambar produk (utama + tambahan)
+ const allImages = product.image_carousel ? [...product.image_carousel] : [];
+
+ if (product.image) {
+ allImages.unshift(product.image); // Tambahkan gambar utama di awal array
+ }
+ console.log(product);
+
+ const [mainImage, setMainImage] = useState(allImages[0] || '');
+
return (
<>
<div className='md:flex md:flex-wrap'>
@@ -83,7 +93,37 @@ const ProductDetail = ({ product }: Props) => {
<div className='md:w-9/12 md:flex md:flex-col md:pr-4 md:pt-6'>
<div className='md:flex md:flex-wrap'>
<div className='md:w-4/12'>
- <ProductImage product={product} />
+ <ProductImage product={{ ...product, image: mainImage }} />
+
+ {/* Carousel horizontal */}
+ {allImages.length > 0 && (
+ <div className='mt-4 overflow-x-auto'>
+ <div className='flex space-x-3 pb-3'>
+ {allImages.map((img, index) => (
+ <div
+ key={index}
+ className={`flex-shrink-0 w-16 h-16 cursor-pointer border-2 rounded-md transition-colors ${
+ mainImage === img
+ ? 'border-red-500 ring-2 ring-red-200'
+ : 'border-gray-200 hover:border-gray-300'
+ }`}
+ onClick={() => setMainImage(img)}
+ >
+ <img
+ src={img}
+ alt={`Thumbnail ${index + 1}`}
+ className='w-full h-full object-cover rounded-sm'
+ loading='lazy'
+ onError={(e) => {
+ (e.target as HTMLImageElement).src =
+ '/path/to/fallback-image.jpg';
+ }}
+ />
+ </div>
+ ))}
+ </div>
+ </div>
+ )}
</div>
<div className='md:w-8/12 px-4 md:pl-6'>
diff --git a/src-migrate/modules/promo/components/Voucher.tsx b/src-migrate/modules/promo/components/Voucher.tsx
index 034d13e9..0c225c74 100644
--- a/src-migrate/modules/promo/components/Voucher.tsx
+++ b/src-migrate/modules/promo/components/Voucher.tsx
@@ -18,6 +18,7 @@ interface Voucher {
name: string;
description: string;
code: string;
+ voucher_category: [];
}
const VoucherComponent = () => {