diff --git a/frontend/src/components/ui/ReviewCarousel.jsx b/frontend/src/components/ui/ReviewCarousel.jsx index b7f0699b..c2e14b44 100644 --- a/frontend/src/components/ui/ReviewCarousel.jsx +++ b/frontend/src/components/ui/ReviewCarousel.jsx @@ -71,15 +71,16 @@ const ReviewCarousel = () => { const nextSlide = () => { setCurrentIndex((prevIndex) => - prevIndex === reviews.length - 4 ? 0 : prevIndex + 1 + prevIndex === reviews.length - 6 ? 0 : prevIndex + 1 ); }; const prevSlide = () => { setCurrentIndex((prevIndex) => - prevIndex === 0 ? reviews.length - 4 : prevIndex - 1 + prevIndex === 0 ? reviews.length - 6 : prevIndex - 1 ); }; + const [cardsToShow, setCardsToShow] = useState(1); const updateCardsToShow = () => { @@ -94,7 +95,10 @@ const ReviewCarousel = () => { updateCardsToShow(); window.addEventListener('resize', updateCardsToShow); + const intervalId = setInterval(nextSlide, 3000); // Change slide every 3 seconds + return () => { + clearInterval(intervalId); // Cleanup interval on unmount window.removeEventListener('resize', updateCardsToShow); }; }, []); @@ -107,8 +111,8 @@ const ReviewCarousel = () => { -