"use client"; import { useState, useRef, useEffect } from "react"; import styles from "./ChannelFAQ.module.css"; import { MessageCircle, ChevronDown } from "lucide-react"; interface FAQItem { question: string; answer: string; } interface ChannelFAQProps { faqs: FAQItem[]; channelTitle: string; } export default function ChannelFAQ({ faqs, channelTitle }: ChannelFAQProps) { const [openIndex, setOpenIndex] = useState(0); // First item open by default const toggleFAQ = (index: number) => { setOpenIndex(openIndex === index ? null : index); }; return (
{/* Left Side: Static Content */}
Frequently Asked Questions

Frequently asked questions

Got questions about how SocialBuddy works with {channelTitle}? We've got answers. If you need more help, our support team is just a click away.

{/* Right Side: Accordion List */}
{faqs.map((faq, index) => ( toggleFAQ(index)} /> ))}
); } // Sub-component for individual item to handle height animation cleanly function FAQItemCard({ item, isOpen, onClick }: { item: FAQItem, isOpen: boolean, onClick: () => void }) { const contentRef = useRef(null); const [height, setHeight] = useState(0); useEffect(() => { if (isOpen && contentRef.current) { setHeight(contentRef.current.scrollHeight); } else { setHeight(0); } }, [isOpen]); return (
{item.answer}
); }