diff --git a/apps/spa/src/components/ProductImageGallery.tsx b/apps/spa/src/components/ProductImageGallery.tsx index 64fda32..c2aa074 100644 --- a/apps/spa/src/components/ProductImageGallery.tsx +++ b/apps/spa/src/components/ProductImageGallery.tsx @@ -12,84 +12,67 @@ export default function ProductImageGallery({ images, fallback, alt = 'Product I const [currentIndex, setCurrentIndex] = useState(0) // Sort images by order if they exist, else just use the array - const sortedImages = images?.length ? [...images].sort((a, b) => a.order - b.order) : [] - const hasImages = sortedImages.length > 0 + const sortedImages = images?.length ? [...images].sort((a, b) => (a.order || 0) - (b.order || 0)) : [] - const currentImageUrl = hasImages ? sortedImages[currentIndex].url : fallback - - const handleNext = () => { - setCurrentIndex((prev) => (prev === sortedImages.length - 1 ? 0 : prev + 1)) - } + if (sortedImages.length === 0) return null - const handlePrev = () => { - setCurrentIndex((prev) => (prev === 0 ? sortedImages.length - 1 : prev - 1)) - } - - return ( -
- {/* Main Image */} -
+ // If there's only one image, don't show thumbnails + if (sortedImages.length === 1) { + return ( +
{alt} { (e.target as HTMLImageElement).src = fallback }} /> -
- {badgeText && ( -
+
{badgeText}
)} +
+ ) + } - {/* Navigation Arrows */} - {sortedImages.length > 1 && ( - <> - - - - )} + return ( +
+ {/* Thumbnails */} +
+ {sortedImages.map((image, idx) => ( + + ))}
- {/* Thumbnails */} - {sortedImages.length > 1 && ( -
- {sortedImages.map((image, idx) => ( - - ))} -
- )} + {/* Main Image */} +
+ {alt} { (e.target as HTMLImageElement).src = fallback }} + /> + {badgeText && ( +
+ {badgeText} +
+ )} +
) } diff --git a/apps/spa/src/pages/ProductDetailPage.tsx b/apps/spa/src/pages/ProductDetailPage.tsx index e33db1a..850065b 100644 --- a/apps/spa/src/pages/ProductDetailPage.tsx +++ b/apps/spa/src/pages/ProductDetailPage.tsx @@ -185,7 +185,7 @@ export default function ProductDetailPage() { -
+
{/* Breadcrumb */}
{t('common.home')}