summaryrefslogtreecommitdiff
path: root/lib/project-gtc/table/project-gtc-table-toolbar-actions.tsx
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-06-20 11:37:31 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-06-20 11:37:31 +0000
commitaa86729f9a2ab95346a2851e3837de1c367aae17 (patch)
treeb601b18b6724f2fb449c7fa9ea50cbd652a8077d /lib/project-gtc/table/project-gtc-table-toolbar-actions.tsx
parent95bbe9c583ff841220da1267630e7b2025fc36dc (diff)
(대표님) 20250620 작업사항
Diffstat (limited to 'lib/project-gtc/table/project-gtc-table-toolbar-actions.tsx')
-rw-r--r--lib/project-gtc/table/project-gtc-table-toolbar-actions.tsx74
1 files changed, 74 insertions, 0 deletions
diff --git a/lib/project-gtc/table/project-gtc-table-toolbar-actions.tsx b/lib/project-gtc/table/project-gtc-table-toolbar-actions.tsx
new file mode 100644
index 00000000..ec6ba053
--- /dev/null
+++ b/lib/project-gtc/table/project-gtc-table-toolbar-actions.tsx
@@ -0,0 +1,74 @@
+"use client"
+
+import * as React from "react"
+import { useRouter } from "next/navigation"
+import { type Table } from "@tanstack/react-table"
+import { Download, Plus } from "lucide-react"
+
+import { exportTableToExcel } from "@/lib/export"
+import { Button } from "@/components/ui/button"
+import { DeleteGtcFileDialog } from "./delete-gtc-file-dialog"
+import { AddProjectDialog } from "./add-project-dialog"
+import { ProjectGtcView } from "@/db/schema"
+
+interface ProjectGtcTableToolbarActionsProps {
+ table: Table<ProjectGtcView>
+}
+
+export function ProjectGtcTableToolbarActions({ table }: ProjectGtcTableToolbarActionsProps) {
+ const router = useRouter()
+ const [showAddProjectDialog, setShowAddProjectDialog] = React.useState(false)
+
+ return (
+ <div className="flex items-center gap-2">
+ {/** 1) 선택된 로우가 있으면 삭제 다이얼로그 */}
+ {table.getFilteredSelectedRowModel().rows.length > 0 ? (
+ <DeleteGtcFileDialog
+ projects={table
+ .getFilteredSelectedRowModel()
+ .rows.map((row) => row.original)}
+ onSuccess={() => {
+ table.toggleAllRowsSelected(false)
+ router.refresh()
+ }}
+ />
+ ) : null}
+
+ {/** 2) GTC 추가 버튼 */}
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => setShowAddProjectDialog(true)}
+ className="gap-2"
+ >
+ <Plus className="size-4" aria-hidden="true" />
+ <span className="hidden sm:inline">GTC 추가</span>
+ </Button>
+
+ {/** 3) Export 버튼 */}
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() =>
+ exportTableToExcel(table, {
+ filename: "project-gtc-list",
+ excludeColumns: ["select", "download", "actions"],
+ })
+ }
+ className="gap-2"
+ >
+ <Download className="size-4" aria-hidden="true" />
+ <span className="hidden sm:inline">Export</span>
+ </Button>
+
+ {/** 4) 프로젝트 추가 다이얼로그 */}
+ <AddProjectDialog
+ open={showAddProjectDialog}
+ onOpenChange={setShowAddProjectDialog}
+ onSuccess={() => {
+ router.refresh()
+ }}
+ />
+ </div>
+ )
+} \ No newline at end of file