import Modal from "@/components/shared/Modal"; import { useEffect, useState } from "react"; interface ModalWithTabsProps { open: boolean; setOpen: (v: boolean) => void; icon?: React.ReactNode; label?: string; description?: string; tabs: TabProps[]; } type TabProps = { title: string; children: React.ReactNode; }; export default function ModalWithTabs({ open, setOpen, tabs, icon, label, description }: ModalWithTabsProps) { const [activeTab, setActiveTab] = useState(0); const handleTabClick = (index: number) => { setActiveTab(index); }; useEffect(() => { if (!open) { setActiveTab(0); } }, [open]); return (
{icon &&
{icon}
}
{label &&
{label}
} {description &&
{description}
}
{tabs.map((tab, index) => ( ))}
{tabs[activeTab].children}
); }