import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "@/components/ui/accordion"; import type { Messages } from "@/types/messages"; interface FAQMessage { [key: string]: string; } interface FAQ { question: string; answer: string; } const generateFAQs = (messages: { text: { faqs: FAQMessage } }): FAQ[] => { const faqs: FAQ[] = []; const faqsData = messages.text.faqs; // Get the total number of questions (by finding keys starting with question_) const questionKeys = Object.keys(faqsData).filter((key) => key.startsWith("question_") ); // Automatically generate FAQ array based on the number of questions questionKeys.forEach((qKey) => { const index = qKey.split("_")[1]; // Get the numeric index const aKey = `answer_${index}`; if (faqsData[aKey]) { // Ensure the corresponding answer exists faqs.push({ question: faqsData[qKey], answer: faqsData[aKey], }); } }); return faqs; }; interface FAQSectionProps { isMainPage?: boolean; // Whether it is the FAQ section of the main page className?: string; // Allow passing custom className showTitle?: boolean; // Whether to display the title titleClassName?: string; // Title style class lang?: string; messages: Messages; } // Control the level and style of the title through props, so it can be used on other pages as well as on a standalone page export default function FAQSection({ isMainPage = false, className = "", showTitle = true, titleClassName = "", messages, }: FAQSectionProps) { const faqs = generateFAQs(messages); // Set default styles for different scenarios const containerClasses = `container mx-auto px-4 py-8 ${className}`; const defaultTitleClasses = "font-bold mb-8"; const titleClasses = `${defaultTitleClasses} ${titleClassName}`.trim(); return (