diff --git a/components/communityImages.jsx b/components/communityImages.jsx index a2d0012..25bec04 100644 --- a/components/communityImages.jsx +++ b/components/communityImages.jsx @@ -1,23 +1,56 @@ -import Image from 'next/image'; +import Image from "next/image"; +import { useState } from "react"; export default function CommunityImages({ images, basePath }) { + const [currentIndex, setCurrentIndex] = useState(0); + + const nextImage = () => { + setCurrentIndex((prevIndex) => (prevIndex + 1) % images.length); + }; + + const prevImage = () => { + setCurrentIndex( + (prevIndex) => (prevIndex - 1 + images.length) % images.length + ); + }; + return ( -
{image.name}
-{images[currentIndex].name}