'use client'; import { useState } from 'react'; import { useLanguage } from '@/context/LanguageContext'; import { FaqItem } from '@/lib/api'; import Card from '@/components/ui/Card'; import { ChevronDownIcon } from '@heroicons/react/24/outline'; import clsx from 'clsx'; // Receives the FAQ list already fetched on the server so the questions and // answers are present in the initial HTML for crawlers. The accordion below is // purely a visual toggle; the answer text stays in the DOM either way. export default function FaqClient({ initialFaqs }: { initialFaqs: FaqItem[] }) { const { locale } = useLanguage(); const [openIndex, setOpenIndex] = useState(null); const toggleFAQ = (index: number) => { setOpenIndex(openIndex === index ? null : index); }; return (

{locale === 'es' ? 'Preguntas Frecuentes' : 'Frequently Asked Questions'}

{locale === 'es' ? 'Encuentra respuestas a las preguntas más comunes sobre Spanglish' : 'Find answers to the most common questions about Spanglish'}

{initialFaqs.length === 0 ? (

{locale === 'es' ? 'No hay preguntas frecuentes publicadas en este momento.' : 'No FAQ questions are published at the moment.'}

) : (
{initialFaqs.map((faq, index) => (
{locale === 'es' && faq.answerEs ? faq.answerEs : faq.answer}
))}
)}

{locale === 'es' ? '¿Todavía tienes preguntas?' : 'Still have questions?'}

{locale === 'es' ? 'No dudes en contactarnos. ¡Estamos aquí para ayudarte!' : "Don't hesitate to reach out. We're here to help!"}

{locale === 'es' ? 'Contáctanos' : 'Contact Us'}
); }