'use client'; /** Full-width product carousel with autoplay and manual navigation. */ import {useCallback, useEffect, useRef, useState} from 'react'; import {LeftOutlined, RightOutlined} from '@ant-design/icons'; import {useLanguage} from '@/app/context/LanguageContext'; import {accountCopy} from '@/data/account'; const AUTOPLAY_DELAY = 5000; // Advance every five seconds. export default function HeroSection() { const {t, dir, locale} = useLanguage(); const slides = t.hero.slides; const [activeIndex, setActiveIndex] = useState(0); const timerRef = useRef | null>(null); // Wrap around after the last slide. const goToNext = useCallback(() => { setActiveIndex((prev) => (prev + 1) % slides.length); }, [slides.length]); const goToPrev = useCallback(() => { setActiveIndex((prev) => (prev - 1 + slides.length) % slides.length); }, [slides.length]); // Restart the autoplay timer after manual navigation. const restartAutoplay = useCallback(() => { if (timerRef.current) clearInterval(timerRef.current); timerRef.current = setInterval(goToNext, AUTOPLAY_DELAY); }, [goToNext]); useEffect(() => { restartAutoplay(); return () => { if (timerRef.current) clearInterval(timerRef.current); }; }, [restartAutoplay]); const handleManualNav = (direction: 'next' | 'prev') => { if (direction === 'next') goToNext(); else goToPrev(); restartAutoplay(); // Reset the delay after a manual click. }; const slide = slides[activeIndex]; return (
{/* ------------------------------------------------------------------ */} {/* Decorative brand-colored shape. */} {/* ------------------------------------------------------------------ */}
{/* ------------------------------------------------------------------ */} {/* Fade between overlapping product images. */} {/* Use opacity transitions for smooth slide changes. */} {/* ------------------------------------------------------------------ */}
{slides.map((s, i) => (
{s.titleLines.join('
))}
{/* Overlay for text readability. */}
{/* ------------------------------------------------------------------ */} {/* Active slide headline, description, and call to action. */} {/* ------------------------------------------------------------------ */}
{slide.kicker}

{slide.titleLines.map((line, i) => ( {line} ))}

{slide.sub}

{/* ------------------------------------------------------------------ */} {/* Previous and next slide controls. */} {/* ------------------------------------------------------------------ */} {/* Jump directly to a slide using the indicators. */}
{slides.map((s, i) => (
); }