From 02b1cf005cf3e1df64183d20ba42930eb2767a9f Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Thu, 21 Aug 2025 06:57:36 +0000
Subject: (대표님, 최겸) 설계메뉴추가, 작업사항 업데이트 설계메뉴 - 문서관리
 설계메뉴 - 벤더 데이터 gtc 메뉴 업데이트 정보시스템 - 메뉴리스트 및 정보
 업데이트 파일 라우트 업데이트 엑셀임포트 개선 기본계약 개선 벤더 가입과정
 변경 및 개선 벤더 기본정보 - pq 돌체 오류 수정 및 개선 벤더 로그인 과정
 이메일 오류 수정
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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

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

diff --git a/lib/basic-contract/vendor-table/basicContract-table-toolbar-actions.tsx b/lib/basic-contract/vendor-table/basicContract-table-toolbar-actions.tsx
index 2e5e4471..1fc6fe6b 100644
--- a/lib/basic-contract/vendor-table/basicContract-table-toolbar-actions.tsx
+++ b/lib/basic-contract/vendor-table/basicContract-table-toolbar-actions.tsx
@@ -1,9 +1,10 @@
 "use client"
 
 import * as React from "react"
-import { type Task } from "@/db/schema/tasks"
 import { type Table } from "@tanstack/react-table"
-import { Download, Upload } from "lucide-react"
+import { Download } from "lucide-react"
+import { useParams } from "next/navigation"
+import { useTranslation } from "@/i18n/client"
 
 import { exportTableToExcel } from "@/lib/export"
 import { Button } from "@/components/ui/button"
@@ -15,9 +16,19 @@ interface TemplateTableToolbarActionsProps {
 }
 
 export function BasicContractTableToolbarActions({ table }: TemplateTableToolbarActionsProps) {
-  // 파일 input을 숨기고, 버튼 클릭 시 참조해 클릭하는 방식
+  const params = useParams()
+  const lng = (params?.lng as string) || "ko"
+  const { t, ready } = useTranslation(lng, "procurement")
 
-  const inPendingContracts = React.useMemo(() => {
+  // 안전한 번역 함수
+  const safeT = React.useCallback((key: string, fallback: string) => {
+    if (!ready) return fallback;
+    const translated = t(key);
+    return translated === key ? fallback : translated;
+  }, [t, ready]);
+
+  // PENDING 상태인 선택된 계약서들
+  const pendingContracts = React.useMemo(() => {
     return table
       .getFilteredSelectedRowModel()
       .rows
@@ -25,31 +36,35 @@ export function BasicContractTableToolbarActions({ table }: TemplateTableToolbar
       .filter(contract => contract.status === "PENDING");
   }, [table.getFilteredSelectedRowModel().rows]);
 
+  // 선택된 행이 있는지 확인
+  const hasSelectedRows = table.getFilteredSelectedRowModel().rows.length > 0;
 
   return (
     <div className="flex items-center gap-2">
+      {/* 서명 버튼 - 항상 표시하되 내부에서 조건 체크 */}
+      <BasicContractSignDialog
+        contracts={pendingContracts}
+        onSuccess={() => table.toggleAllRowsSelected(false)}
+        hasSelectedRows={hasSelectedRows}
+        t={safeT}
+      />
 
-      {table.getFilteredSelectedRowModel().rows.length > 0 ? (
-        <BasicContractSignDialog
-          contracts={inPendingContracts}
-          onSuccess={() => table.toggleAllRowsSelected(false)}
-        />
-      ) : null}
-
-      {/** 4) Export 버튼 */}
+      {/* Export 버튼 */}
       <Button
         variant="outline"
         size="sm"
         onClick={() =>
           exportTableToExcel(table, {
-            filename: "basci-contract-requested-list",
+            filename: "basic-contract-requested-list",
             excludeColumns: ["select", "actions"],
           })
         }
         className="gap-2"
       >
         <Download className="size-4" aria-hidden="true" />
-        <span className="hidden sm:inline">Export</span>
+        <span className="hidden sm:inline">
+          {safeT("basicContracts.toolbar.export", lng === 'ko' ? "내보내기" : "Export")}
+        </span>
       </Button>
     </div>
   )
-- 
cgit v1.2.3

