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

---
 .../vendor-table/basic-contract-table.tsx          | 98 +++++++++++++++-------
 1 file changed, 68 insertions(+), 30 deletions(-)

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

diff --git a/lib/basic-contract/vendor-table/basic-contract-table.tsx b/lib/basic-contract/vendor-table/basic-contract-table.tsx
index 34e15ae3..f2575024 100644
--- a/lib/basic-contract/vendor-table/basic-contract-table.tsx
+++ b/lib/basic-contract/vendor-table/basic-contract-table.tsx
@@ -1,6 +1,8 @@
 "use client";
 
 import * as React from "react";
+import { useParams } from "next/navigation";
+import { useTranslation } from "react-i18next";
 import { DataTable } from "@/components/data-table/data-table";
 import { Button } from "@/components/ui/button";
 import { Plus, Loader2 } from "lucide-react";
@@ -17,7 +19,6 @@ import { getBasicContracts, getBasicContractsByVendorId } from "../service";
 import { BasicContractView } from "@/db/schema";
 import { BasicContractTableToolbarActions } from "./basicContract-table-toolbar-actions";
 
-
 interface BasicTemplateTableProps {
   promises: Promise<
     [
@@ -26,44 +27,85 @@ interface BasicTemplateTableProps {
   >
 }
 
-
 export function BasicContractsVendorTable({ promises }: BasicTemplateTableProps) {
-
-
+  const params = useParams();
+  const lng = (params?.lng as string) || "ko";
+  const { t, ready } = useTranslation(lng, "procurement");
+  
   const [rowAction, setRowAction] =
     React.useState<DataTableRowAction<BasicContractView> | null>(null)
-
-
+  
   const [{ data, pageCount }] =
     React.use(promises)
 
-    // console.log(data)
-
-  // 컬럼 설정 - 외부 파일에서 가져옴
+    console.log(data,"data")
+
+  // 안전한 번역 함수 (fallback 포함)
+  const safeT = React.useCallback((key: string, fallback: string) => {
+    if (!ready) return fallback;
+    const translated = t(key);
+    return translated === key ? fallback : translated;
+  }, [t, ready]);
+
+  // 디버깅용 로그 (개발환경에서만)
+  React.useEffect(() => {
+    if (process.env.NODE_ENV === 'development') {
+      console.log('Translation ready:', ready);
+      console.log('Current language:', lng);
+      console.log('Template name translation:', t("basicContracts.templateName"));
+      console.log('Status PENDING translation:', t("basicContracts.statusValues.PENDING"));
+    }
+  }, [ready, lng, t]);
+
+  // 컬럼 설정 - 번역이 준비된 후에만 생성
   const columns = React.useMemo(
-    () => getColumns({ setRowAction }),
-    [setRowAction]
+    () => {
+      if (!ready) return []; // 번역이 준비되지 않으면 빈 배열 반환
+      return getColumns({ setRowAction, locale: lng, t });
+    },
+    [setRowAction, lng, t, ready]
   )
 
-  // config 기반으로 필터 필드 설정
-  const advancedFilterFields: DataTableAdvancedFilterField<BasicContractView>[] = [
-    { id: "templateName", label: "템플릿명", type: "text" },
-    {
-      id: "status", label: "상태", type: "select", options: [
-        { label: "서명대기", value: "PENDING" },
-        { label: "서명완료", value: "COMPLETED" },
-      ]
-    },
-    { id: "userName", label: "요청자", type: "text" },
-    { id: "createdAt", label: "생성일", type: "date" },
-    { id: "updatedAt", label: "수정일", type: "date" },
-  ];
+  // config 기반으로 필터 필드 설정 - 안전한 번역 함수 사용
+  const advancedFilterFields: DataTableAdvancedFilterField<BasicContractView>[] = React.useMemo(() => {
+    return [
+      { 
+        id: "templateName", 
+        label: safeT("basicContracts.templateName", lng === 'ko' ? "템플릿명" : "Template Name"), 
+        type: "text" 
+      },
+      {
+        id: "status", 
+        label: safeT("basicContracts.status", lng === 'ko' ? "상태" : "Status"), 
+        type: "select", 
+        options: [
+          { 
+            label: safeT("basicContracts.statusValues.PENDING", lng === 'ko' ? "서명대기" : "Pending"), 
+            value: "PENDING" 
+          },
+          { 
+            label: safeT("basicContracts.statusValues.COMPLETED", lng === 'ko' ? "서명완료" : "Completed"), 
+            value: "COMPLETED" 
+          },
+        ]
+      },
+      { 
+        id: "createdAt", 
+        label: safeT("basicContracts.createdAt", lng === 'ko' ? "생성일" : "Created Date"), 
+        type: "date" 
+      },
+      { 
+        id: "updatedAt", 
+        label: safeT("basicContracts.updatedAt", lng === 'ko' ? "수정일" : "Updated Date"), 
+        type: "date" 
+      },
+    ];
+  }, [safeT, lng]);
 
   const { table } = useDataTable({
     data,
     columns,
     pageCount,
-    // filterFields,
     enablePinning: true,
     enableAdvancedFilter: true,
     initialState: {
@@ -77,18 +119,14 @@ export function BasicContractsVendorTable({ promises }: BasicTemplateTableProps)
 
   return (
     <>
-
       <DataTable table={table}>
         <DataTableAdvancedToolbar
           table={table}
           filterFields={advancedFilterFields}
         >
           <BasicContractTableToolbarActions table={table} />
-
         </DataTableAdvancedToolbar>
       </DataTable>
-
     </>
-
   );
-} 
\ No newline at end of file
+}
\ No newline at end of file
-- 
cgit v1.2.3

