"use client"; import { useState, useEffect } from "react"; import { motion, AnimatePresence } from "framer-motion"; import Loader from '@/app/(landing)/components/Loader'; import { useTestimonials } from '@/app/(landing)/home/services/testimonials'; import type { ThemeProps } from '@/app/(landing)/types/ui'; export const Testimonial = ({ isNavyBg }: ThemeProps) => { const { data, isLoading } = useTestimonials(); const [current, setCurrent] = useState(0); const testimonials = data ?? []; useEffect(() => { if (testimonials.length < 2) return; const t = setInterval( () => setCurrent((i) => (i + 1) % testimonials.length), 6000, ); return () => clearInterval(t); }, [testimonials.length]); const item = testimonials[current]; const bg = isNavyBg ? "var(--background)" : "#f9f9f7"; const border = isNavyBg ? "rgba(255,255,255,0.08)" : "rgba(0,0,0,0.08)"; const sub = isNavyBg ? "rgba(255,255,255,0.45)" : "#6a6866"; const text = isNavyBg ? "var(--foreground)" : "#0a0a0a"; if (!isLoading && testimonials.length === 0) return null; // sección se oculta si no hay testimonios return (
{isLoading ? ( ) : ( <>

"{item.quote}"

{item.author && (

{item.author}

)}

{item.company}

{testimonials.length > 1 && (
{testimonials.map((_, i) => (
)} )}
); };