// app/evcp/menu-list/components/export-button.tsx "use client"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Download } from "lucide-react"; import { toast } from "sonner"; import { exportMenusToExcel } from "./excel-export"; interface MenuAssignment { id: number; menuPath: string; menuTitle: string; menuDescription?: string | null; menuGroup?: string | null; sectionTitle: string; domain: string; isActive: boolean; manager1Name?: string | null; manager1Email?: string | null; manager2Name?: string | null; manager2Email?: string | null; } interface ExportButtonProps { menus: MenuAssignment[]; translate: (key: string) => string; } export function ExportButton({ menus, translate }: ExportButtonProps) { const [isExporting, setIsExporting] = useState(false); const handleExport = async () => { if (menus.length === 0) { toast.error("내보낼 데이터가 없습니다."); return; } setIsExporting(true); try { await exportMenusToExcel(menus, translate); toast.success(`${menus.length}개의 메뉴 데이터를 엑셀로 내보냈습니다.`); } catch (error) { console.error("Export error:", error); toast.error("엑셀 파일 생성 중 오류가 발생했습니다."); } finally { setIsExporting(false); } }; return ( ); }