"use client" import { useState } from "react" import Image from "next/image" import { ChevronLeft, ChevronRight } from "lucide-react" import { Button } from "./ui/button" interface ImageGalleryProps { images: string[] } export function ImageGallery({ images }: ImageGalleryProps) { // Check if images is undefined or not an array if (!images || !Array.isArray(images)) { console.error('Images prop is undefined or not an array:', images); return
Error: No images provided
; } const [currentIndex, setCurrentIndex] = useState(0) const goToPrevious = () => { setCurrentIndex((prevIndex) => (prevIndex === 0 ? images.length - 1 : prevIndex - 1)) } const goToNext = () => { setCurrentIndex((prevIndex) => (prevIndex === images.length - 1 ? 0 : prevIndex + 1)) } return (
{`Product
{images.map((_, index) => (
) }