From aa86729f9a2ab95346a2851e3837de1c367aae17 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Fri, 20 Jun 2025 11:37:31 +0000
Subject: (대표님) 20250620 작업사항
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../table/payment-terms-table-toolbar.tsx          | 41 ++++++++++++++++++++--
 1 file changed, 39 insertions(+), 2 deletions(-)

(limited to 'lib/payment-terms/table/payment-terms-table-toolbar.tsx')

diff --git a/lib/payment-terms/table/payment-terms-table-toolbar.tsx b/lib/payment-terms/table/payment-terms-table-toolbar.tsx
index 2466a9e4..51ac9b93 100644
--- a/lib/payment-terms/table/payment-terms-table-toolbar.tsx
+++ b/lib/payment-terms/table/payment-terms-table-toolbar.tsx
@@ -1,16 +1,53 @@
 "use client";
 
 import * as React from "react";
+import { type Table } from "@tanstack/react-table";
+import { Download } from "lucide-react";
+
+import { exportTableToExcel } from "@/lib/export";
+import { Button } from "@/components/ui/button";
+import { DeletePaymentTermsDialog } from "./delete-payment-terms-dialog";
 import { PaymentTermsAddDialog } from "./payment-terms-add-dialog";
+import { paymentTerms } from "@/db/schema/procurementRFQ";
 
-interface PaymentTermsTableToolbarProps {
+interface PaymentTermsTableToolbarActionsProps {
+  table: Table<typeof paymentTerms.$inferSelect>;
   onSuccess?: () => void;
 }
 
-export function PaymentTermsTableToolbar({ onSuccess }: PaymentTermsTableToolbarProps) {
+export function PaymentTermsTableToolbarActions({ table, onSuccess }: PaymentTermsTableToolbarActionsProps) {
   return (
     <div className="flex items-center gap-2">
+      {/** 1) 선택된 로우가 있으면 삭제 다이얼로그 */}
+      {table.getFilteredSelectedRowModel().rows.length > 0 ? (
+        <DeletePaymentTermsDialog
+          paymentTerms={table
+            .getFilteredSelectedRowModel()
+            .rows.map((row) => row.original)}
+          onSuccess={() => {
+            table.toggleAllRowsSelected(false);
+            onSuccess?.();
+          }}
+        />
+      ) : null}
+
       <PaymentTermsAddDialog onSuccess={onSuccess} />
+
+      {/** 3) Export 버튼 */}
+      <Button
+        variant="outline"
+        size="sm"
+        onClick={() =>
+          exportTableToExcel(table, {
+            filename: "payment-terms-list",
+            excludeColumns: ["select", "actions"],
+          })
+        }
+        className="gap-2"
+      >
+        <Download className="size-4" aria-hidden="true" />
+        <span className="hidden sm:inline">Export</span>
+      </Button>
     </div>
   );
 } 
\ No newline at end of file
-- 
cgit v1.2.3

