diff --git a/apps/website/src/app/[lang]/products/[slug]/page.tsx b/apps/website/src/app/[lang]/products/[slug]/page.tsx index 0c31392..4f734c4 100644 --- a/apps/website/src/app/[lang]/products/[slug]/page.tsx +++ b/apps/website/src/app/[lang]/products/[slug]/page.tsx @@ -7,6 +7,7 @@ import ReactMarkdown from 'react-markdown' import remarkGfm from 'remark-gfm' import { getCategoryImage, type Product } from '@homaroma/types' import AddToCartSection from '@/components/AddToCartSection' +import ProductGallery from '@/components/ProductGallery' import DynamicPageRenderer from '@/components/dynamic/DynamicPageRenderer' import ProductCard from '@/components/ProductCard' import { getCategoriesResult, getCmsPageResult, getProduct, getProductResult, getProductsResult } from '@/lib/cms' @@ -154,7 +155,7 @@ export default async function ProductDetailPage({ params }: { params: Promise<{ {announcementSections.length > 0 && ( )} -
+
-
- {productName} - {categoryName && ( -
- {categoryName} -
- )} -
+ img.url) || [imageUrl]} + productName={productName} + categoryName={categoryName} + />
diff --git a/apps/website/src/components/ProductGallery.tsx b/apps/website/src/components/ProductGallery.tsx new file mode 100644 index 0000000..54af41b --- /dev/null +++ b/apps/website/src/components/ProductGallery.tsx @@ -0,0 +1,79 @@ +'use client' + +import { useState } from 'react' +import Image from 'next/image' + +interface Props { + productName: string + categoryName?: string + images: string[] +} + +export default function ProductGallery({ productName, categoryName, images }: Props) { + const [activeIndex, setActiveIndex] = useState(0) + + if (images.length === 0) return null + + // If there's only one image, don't show thumbnails + if (images.length === 1) { + return ( +
+ {productName} + {categoryName && ( +
+ {categoryName} +
+ )} +
+ ) + } + + return ( +
+ {/* Thumbnails */} +
+ {images.map((img, idx) => ( + + ))} +
+ + {/* Main Image */} +
+ {productName} + {categoryName && ( +
+ {categoryName} +
+ )} +
+
+ ) +}