From e0dfb55c5457aec489fc084c4567e791b4c65eb1 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Wed, 26 Mar 2025 00:37:41 +0000 Subject: 3/25 까지의 대표님 작업사항 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client-data-table/data-table-toolbar.tsx | 100 +++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 components/client-data-table/data-table-toolbar.tsx (limited to 'components/client-data-table/data-table-toolbar.tsx') diff --git a/components/client-data-table/data-table-toolbar.tsx b/components/client-data-table/data-table-toolbar.tsx new file mode 100644 index 00000000..286cffd6 --- /dev/null +++ b/components/client-data-table/data-table-toolbar.tsx @@ -0,0 +1,100 @@ +"use client" + +import * as React from "react" +import type { DataTableAdvancedFilterField } from "@/types/table" +import { type Table } from "@tanstack/react-table" + +import { cn } from "@/lib/utils" +import { ClientDataTableViewOptions } from "./data-table-view-options" +import { Button } from "../ui/button" +import { Download } from "lucide-react" + +import { exportTableToExcel } from "@/lib/export_all" +import { ClientDataTableSortList } from "./data-table-sort-list" +import { ClientDataTableGroupList } from "./data-table-group-list" +import { ClientDataTableAdvancedFilter } from "./data-table-filter-list" + +interface DataTableAdvancedToolbarProps + extends React.HTMLAttributes { + table: Table + filterFields: DataTableAdvancedFilterField[] + debounceMs?: number + shallow?: boolean + children?: React.ReactNode +} + +export function ClientDataTableAdvancedToolbar({ + table, + filterFields = [], + debounceMs = 300, + shallow = true, + children, + className, + ...props +}: DataTableAdvancedToolbarProps) { + + // 전체 엑셀 내보내기 + const handleExportAll = async () => { + try { + await exportTableToExcel(table, { + filename: "my-data", + onlySelected: false, + excludeColumns: ["select", "actions", "validation", "requestedAmount", "update"], + useGroupHeader: false, + allPages: true, + + }) + } catch (err) { + console.error("Export error:", err) + // 필요하면 토스트나 알림 처리 + } + } + + + + return ( +
+ {/* 왼쪽: 필터 & 정렬 & 뷰 옵션 */} +
+ + + + + +
+ + {/* 오른쪽: Export 버튼 + children */} +
+ + + {/* 자식 컴포넌트(추가 버튼 등) */} + {children} + + {/* 선택된 행만 내보내기 버튼 예시 (필요 시 주석 해제) */} + {/* + + */} +
+
+ ) +} \ No newline at end of file -- cgit v1.2.3