From c54e2acaed641b7ae2c1a7304b08626f9ca973db Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Wed, 17 Sep 2025 05:39:58 +0000
Subject: (임수민) 기본계약 폐기하기, 수정하기 수정
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../basicContract-table-toolbar-actions.tsx        | 34 ++++++++++++++++++----
 1 file changed, 29 insertions(+), 5 deletions(-)

(limited to 'lib/basic-contract/template/basicContract-table-toolbar-actions.tsx')

diff --git a/lib/basic-contract/template/basicContract-table-toolbar-actions.tsx b/lib/basic-contract/template/basicContract-table-toolbar-actions.tsx
index 439fea26..850dc0a5 100644
--- a/lib/basic-contract/template/basicContract-table-toolbar-actions.tsx
+++ b/lib/basic-contract/template/basicContract-table-toolbar-actions.tsx
@@ -9,6 +9,7 @@ import { exportTableToExcel } from "@/lib/export"
 import { Button } from "@/components/ui/button"
 import { DeleteTemplatesDialog } from "./delete-basicContract-dialog"
 import { AddTemplateDialog } from "./add-basic-contract-template-dialog"
+import { DisposeDocumentsDialog } from "./dispose-documents-dialog"
 import { BasicContractTemplate } from "@/db/schema"
 
 interface TemplateTableToolbarActionsProps {
@@ -17,16 +18,39 @@ interface TemplateTableToolbarActionsProps {
 
 export function TemplateTableToolbarActions({ table }: TemplateTableToolbarActionsProps) {
   // 파일 input을 숨기고, 버튼 클릭 시 참조해 클릭하는 방식
- 
+  const selectedRows = table.getFilteredSelectedRowModel().rows
+  const selectedDocuments = selectedRows.map((row) => row.original)
+  
+  // 선택된 문서들의 상태 확인
+  const hasActiveDocuments = selectedDocuments.some(doc => doc.status === 'ACTIVE')
+  const hasDisposedDocuments = selectedDocuments.some(doc => doc.status === 'DISPOSED')
 
   return (
     <div className="flex items-center gap-2">
       {/** 1) 선택된 로우가 있으면 삭제 다이얼로그 */}
-      {table.getFilteredSelectedRowModel().rows.length > 0 ? (
+      {selectedRows.length > 0 ? (
         <DeleteTemplatesDialog
-          templates={table
-            .getFilteredSelectedRowModel()
-            .rows.map((row) => row.original)}
+          templates={selectedDocuments}
+          onSuccess={() => table.toggleAllRowsSelected(false)}
+        />
+      ) : null}
+
+      {/** 2) 선택된 활성 문서가 있으면 폐기 다이얼로그 */}
+      {selectedRows.length > 0 && hasActiveDocuments ? (
+        <DisposeDocumentsDialog
+          open={false}
+          onOpenChange={() => {}}
+          documents={selectedDocuments.filter(doc => doc.status === 'ACTIVE')}
+          onSuccess={() => table.toggleAllRowsSelected(false)}
+        />
+      ) : null}
+
+      {/** 3) 선택된 폐기 문서가 있으면 복구 다이얼로그 */}
+      {selectedRows.length > 0 && hasDisposedDocuments ? (
+        <DisposeDocumentsDialog
+          open={false}
+          onOpenChange={() => {}}
+          documents={selectedDocuments.filter(doc => doc.status === 'DISPOSED')}
           onSuccess={() => table.toggleAllRowsSelected(false)}
         />
       ) : null}
-- 
cgit v1.2.3

