From bac0228d21b7195065e9cddcc327ae33659c7bcc Mon Sep 17 00:00:00 2001 From: dujinkim Date: Sun, 1 Jun 2025 13:52:21 +0000 Subject: (대표님) 20250601까지 작업사항 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../items-table/item-table-toolbar-actions.tsx | 36 ++++++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'lib/vendors/items-table/item-table-toolbar-actions.tsx') diff --git a/lib/vendors/items-table/item-table-toolbar-actions.tsx b/lib/vendors/items-table/item-table-toolbar-actions.tsx index f7bd2bf6..8be67f71 100644 --- a/lib/vendors/items-table/item-table-toolbar-actions.tsx +++ b/lib/vendors/items-table/item-table-toolbar-actions.tsx @@ -1,3 +1,4 @@ +// components/vendor-items/item-table-toolbar-actions.tsx "use client" import * as React from "react" @@ -8,21 +9,26 @@ import { toast } from "sonner" import { exportTableToExcel } from "@/lib/export" import { Button } from "@/components/ui/button" - // 만약 서버 액션이나 API 라우트를 이용해 업로드 처리한다면 import import { importTasksExcel } from "@/lib/tasks/service" // 예시 -import { VendorItemsView } from "@/db/schema/vendors" +import { + VendorItemsView +} from "@/db/schema/vendors" import { AddItemDialog } from "./add-item-dialog" +import { DeleteVendorItemsDialog } from "./delete-vendor-items-dialog" interface VendorsTableToolbarActionsProps { table: Table vendorId: number } -export function VendorsTableToolbarActions({ table,vendorId }: VendorsTableToolbarActionsProps) { +export function VendorsTableToolbarActions({ table, vendorId }: VendorsTableToolbarActionsProps) { // 파일 input을 숨기고, 버튼 클릭 시 참조해 클릭하는 방식 const fileInputRef = React.useRef(null) + // 선택된 행들 가져오기 + const selectedRows = table.getFilteredSelectedRowModel().rows + // 파일이 선택되었을 때 처리 async function onFileChange(event: React.ChangeEvent) { const file = event.target.files?.[0] @@ -55,7 +61,6 @@ export function VendorsTableToolbarActions({ table,vendorId }: VendorsTableToolb } catch (err) { toast.error("파일 업로드 중 오류가 발생했습니다.") - } } @@ -66,10 +71,21 @@ export function VendorsTableToolbarActions({ table,vendorId }: VendorsTableToolb return (
- - - - {/** 3) Import 버튼 (파일 업로드) */} + + + {/* 삭제 버튼 - 선택된 행이 있을 때만 표시 */} + {selectedRows.length > 0 && ( + row.original)} + onSuccess={() => { + // 삭제 성공 후 선택 해제 + table.toggleAllPageRowsSelected(false) + }} + /> + )} + + {/** Import 버튼 (파일 업로드) */}