"use client" import { useState, useEffect } from "react" import { Card, CardContent } from "@/components/ui/card" import { Button } from "@/components/ui/button" import { ChevronLeftIcon, ChevronRightIcon, StarIcon } from "lucide-react" import Image from "next/image" import { useTranslations } from "next-intl" interface TestimonialsSectionProps { locale: string } export default function TestimonialsSection({ locale }: TestimonialsSectionProps) { const [currentIndex, setCurrentIndex] = useState(0) const [isTransitioning, setIsTransitioning] = useState(false) const t = useTranslations("testimonials") const testimonials = [ { name: "Alex Doe", role: t("testimonial1.role"), content: t("testimonial1.content"), avatar: "/images/Alex Doe.jpeg", rating: 5, }, { name: "Li Jing", role: t("testimonial2.role"), content: t("testimonial2.content"), avatar: "/images/lijing.jpg", rating: 5, }, { name: "Sarah Johnson", role: t("testimonial3.role"), content: t("testimonial3.content"), avatar: "/images/Sarah Johnson.jpg", rating: 5, }, ] const changeTestimonial = (newIndex: number) => { if (isTransitioning || newIndex === currentIndex) return setIsTransitioning(true) setTimeout(() => { setCurrentIndex(newIndex) setTimeout(() => { setIsTransitioning(false) }, 50) }, 150) } const nextTestimonial = () => { const newIndex = (currentIndex + 1) % testimonials.length changeTestimonial(newIndex) } const prevTestimonial = () => { const newIndex = (currentIndex - 1 + testimonials.length) % testimonials.length changeTestimonial(newIndex) } useEffect(() => { const interval = setInterval(() => { if (!isTransitioning) { nextTestimonial() } }, 5000) return () => clearInterval(interval) }, [currentIndex, isTransitioning]) return (

{t("title")}

{t("subtitle")}

{/* Stars */}
{[...Array(testimonials[currentIndex].rating)].map((_, i) => ( ))}
{/* Content */}
"{testimonials[currentIndex].content}"
{/* Author */}
{testimonials[currentIndex].name}
{testimonials[currentIndex].name}
{testimonials[currentIndex].role}
{/* Navigation */}
{/* Dots */}
{testimonials.map((_, index) => (
) }