From dfdfae3018f8499240f48d28ce634f4a5c56e006 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Wed, 2 Apr 2025 09:54:08 +0000
Subject: 벤더 코멘트 처리
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/pq/table/pq-table-toolbar-actions.tsx | 86 +++++++++++++++++++++----------
 1 file changed, 59 insertions(+), 27 deletions(-)

(limited to 'lib/pq/table/pq-table-toolbar-actions.tsx')

diff --git a/lib/pq/table/pq-table-toolbar-actions.tsx b/lib/pq/table/pq-table-toolbar-actions.tsx
index 1d151520..1790caf8 100644
--- a/lib/pq/table/pq-table-toolbar-actions.tsx
+++ b/lib/pq/table/pq-table-toolbar-actions.tsx
@@ -2,23 +2,41 @@
 
 import * as React from "react"
 import { type Table } from "@tanstack/react-table"
-import { Download, Send, Upload } from "lucide-react"
+import { Download, FileDown, Upload } from "lucide-react"
 import { toast } from "sonner"
 
 import { exportTableToExcel } from "@/lib/export"
 import { Button } from "@/components/ui/button"
+import {
+  DropdownMenu,
+  DropdownMenuContent,
+  DropdownMenuItem,
+  DropdownMenuTrigger,
+} from "@/components/ui/dropdown-menu"
+
 import { DeletePqsDialog } from "./delete-pqs-dialog"
 import { AddPqDialog } from "./add-pq-dialog"
 import { PqCriterias } from "@/db/schema/pq"
+import { ImportPqButton } from "./import-pq-button"
+import { exportPqTemplate } from "./pq-excel-template"
 
-
-interface DocTableToolbarActionsProps {
+interface PqTableToolbarActionsProps {
   table: Table<PqCriterias>
+  currentProjectId?: number
 }
 
-export function PqTableToolbarActions({ table}: DocTableToolbarActionsProps) {
-
-
+export function PqTableToolbarActions({ 
+  table, 
+  currentProjectId
+}: PqTableToolbarActionsProps) {
+  const [refreshKey, setRefreshKey] = React.useState(0)
+  const isProjectSpecific = !!currentProjectId
+  
+  // Import 성공 후 테이블 갱신
+  const handleImportSuccess = () => {
+    setRefreshKey(prev => prev + 1)
+  }
+  
   return (
     <div className="flex items-center gap-2">
       {table.getFilteredSelectedRowModel().rows.length > 0 ? (
@@ -29,27 +47,41 @@ export function PqTableToolbarActions({ table}: DocTableToolbarActionsProps) {
           onSuccess={() => table.toggleAllRowsSelected(false)}
         />
       ) : null}
-
-
-      <AddPqDialog />
-
-      <Button
-        variant="outline"
-        size="sm"
-        onClick={() =>
-          exportTableToExcel(table, {
-            filename: "Document-list",
-            excludeColumns: ["select", "actions"],
-          })
-        }
-        className="gap-2"
-      >
-        <Download className="size-4" aria-hidden="true" />
-        <span className="hidden sm:inline">Export</span>
-      </Button>
-
-
-
+      
+      <AddPqDialog currentProjectId={currentProjectId} />
+      
+      {/* Import 버튼 */}
+      <ImportPqButton 
+        projectId={currentProjectId} 
+        onSuccess={handleImportSuccess} 
+      />
+      
+      {/* Export 드롭다운 메뉴 */}
+      <DropdownMenu>
+        <DropdownMenuTrigger asChild>
+          <Button variant="outline" size="sm" className="gap-2">
+            <Download className="size-4" aria-hidden="true" />
+            <span className="hidden sm:inline">Export</span>
+          </Button>
+        </DropdownMenuTrigger>
+        <DropdownMenuContent align="end">
+          <DropdownMenuItem
+            onClick={() =>
+              exportTableToExcel(table, {
+                filename: isProjectSpecific ? `project-${currentProjectId}-pq-criteria` : "general-pq-criteria",
+                excludeColumns: ["select", "actions"],
+              })
+            }
+          >
+            <FileDown className="mr-2 h-4 w-4" />
+            <span>현재 데이터 내보내기</span>
+          </DropdownMenuItem>
+          <DropdownMenuItem onClick={() => exportPqTemplate(isProjectSpecific)}>
+            <FileDown className="mr-2 h-4 w-4" />
+            <span>{isProjectSpecific ? '프로젝트용' : '일반'} 템플릿 다운로드</span>
+          </DropdownMenuItem>
+        </DropdownMenuContent>
+      </DropdownMenu>
     </div>
   )
 }
\ No newline at end of file
-- 
cgit v1.2.3

