import { useState } from "react"; import { motion, AnimatePresence } from "motion/react"; import { Plus } from "lucide-react"; import ScrollReveal from "@/components/ui/ScrollReveal"; import Button from "@/components/ui/Button"; import TextAnimation from "@/components/ui/TextAnimation"; import { cls } from "@/lib/utils"; type FaqItem = { question: string; answer: string; }; const FaqTwoColumn = ({ tag, title, description, primaryButton, secondaryButton, items, }: { tag: string; title: string; description: string; primaryButton?: { text: string; href: string }; secondaryButton?: { text: string; href: string }; items: FaqItem[]; }) => { const [activeIndex, setActiveIndex] = useState(null); const handleToggle = (index: number) => { setActiveIndex(activeIndex === index ? null : index); }; const halfLength = Math.ceil(items.length / 2); const firstColumn = items.slice(0, halfLength); const secondColumn = items.slice(halfLength); const renderAccordionItem = (item: FaqItem, index: number) => (
handleToggle(index)} className="p-3 2xl:p-4 rounded secondary-button cursor-pointer select-none" >

{item.question}

{activeIndex === index && (

{item.answer}

)}
); return (

{tag}

{(primaryButton || secondaryButton) && (
{primaryButton &&
)}
{firstColumn.map((item, index) => renderAccordionItem(item, index))}
{secondColumn.length > 0 && (
{secondColumn.map((item, index) => renderAccordionItem(item, index + halfLength))}
)}
); }; export default FaqTwoColumn;