"use client"; import { useState } from "react"; import Image from "next/image"; interface ImageCarrouselProps { images: string[]; titre: string; } export default function ImageCarrousel({ images, titre }: ImageCarrouselProps) { const [currentIndex, setCurrentIndex] = useState(0); const goToPrevious = () => { const isFirstSlide = currentIndex === 0; const newIndex = isFirstSlide ? images.length - 1 : currentIndex - 1; setCurrentIndex(newIndex); }; const goToNext = () => { const isLastSlide = currentIndex === images.length - 1; const newIndex = isLastSlide ? 0 : currentIndex + 1; setCurrentIndex(newIndex); }; const goToSlide = (slideIndex: number) => { setCurrentIndex(slideIndex); }; if (!images || images.length === 0) { return (
Aucune image disponible
); } return (
{/* Image principale */}
{`${titre}
{/* Flèche Gauche */} {images.length > 1 && (
)} {/* Flèche Droite */} {images.length > 1 && (
)} {/* Indicateurs (points) */}
{images.map((_, slideIndex) => (
); }