From d28c43b2d33bac51c69ac7417a14f9fe83f2a25f Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Wed, 29 Oct 2025 07:44:16 +0000
Subject: (대표님) menu list excel export 개발
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/menu-list/table/export-button.tsx | 64 +++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)
 create mode 100644 lib/menu-list/table/export-button.tsx

(limited to 'lib/menu-list/table/export-button.tsx')

diff --git a/lib/menu-list/table/export-button.tsx b/lib/menu-list/table/export-button.tsx
new file mode 100644
index 00000000..320e495f
--- /dev/null
+++ b/lib/menu-list/table/export-button.tsx
@@ -0,0 +1,64 @@
+// 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 (
+    <Button
+      onClick={handleExport}
+      disabled={isExporting || menus.length === 0}
+      variant="outline"
+      size="sm"
+    >
+      <Download className="mr-2 h-4 w-4" />
+      {isExporting ? "내보내는 중..." : `엑셀 다운로드 (${menus.length}개)`}
+    </Button>
+  );
+}
\ No newline at end of file
-- 
cgit v1.2.3

