From c54a2445b6285d06c0ce3afa1cd3aa6aecf6de94 Mon Sep 17 00:00:00 2001
From: joonhoekim <26rote@gmail.com>
Date: Mon, 24 Nov 2025 20:13:50 +0900
Subject: (김준회) dolce rebuild: i18n 지원
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/dolce/table/detail-drawing-columns.tsx | 119 +++++++++++++++++++++++++++++
 1 file changed, 119 insertions(+)

(limited to 'lib/dolce/table/detail-drawing-columns.tsx')

diff --git a/lib/dolce/table/detail-drawing-columns.tsx b/lib/dolce/table/detail-drawing-columns.tsx
index 7f519179..77d25953 100644
--- a/lib/dolce/table/detail-drawing-columns.tsx
+++ b/lib/dolce/table/detail-drawing-columns.tsx
@@ -2,7 +2,41 @@
 
 import { ColumnDef } from "@tanstack/react-table";
 import { DetailDwgReceiptItem } from "../actions";
+import { formatDolceDateTime } from "../utils/date-formatter";
 
+// DOLCE API ENM 필드가 제대로 번역되지 않아 직접 매핑
+const DRAWING_USAGE_MAP: Record<string, { ko: string; en: string }> = {
+  APP: { ko: "승인용", en: "Approval" },
+  WOR: { ko: "작업용", en: "Working" },
+  REC: { ko: "입수용 / GTT→SHI", en: "GTT→SHI" },
+  SUB: { ko: "제출용 / SHI→GTT", en: "SHI→GTT" },
+};
+
+const REGISTER_KIND_MAP: Record<string, { ko: string; en: string }> = {
+  APPR: { ko: "승인 제출용 도면(Full)", en: "For Approval(Full)" },
+  APPP: { ko: "승인 제출용 도면(Partial)", en: "For Approval(Partial)" },
+  WORK: { ko: "작업용 입수도면(Full)", en: "For Working(Full)" },
+  WORP: { ko: "작업용 입수도면(Partial)", en: "For Working(Partial)" },
+  RECW: { ko: "Working 도면입수(GTT→SHI)", en: "Working Dwg(GTT→SHI)" },
+  RECP: { ko: "Pre. 도면입수(GTT→SHI)", en: "Pre. Dwg(GTT→SHI)" },
+};
+
+// 카테고리는 API에서 ENM이 제공되는 것으로 가정 (필요시 추가)
+const translateDrawingUsage = (code: string | null, lng: string): string => {
+  if (!code) return "";
+  const mapped = DRAWING_USAGE_MAP[code];
+  if (!mapped) return code;
+  return lng === "en" ? mapped.en : mapped.ko;
+};
+
+const translateRegisterKind = (code: string | null, lng: string): string => {
+  if (!code) return "";
+  const mapped = REGISTER_KIND_MAP[code];
+  if (!mapped) return code;
+  return lng === "en" ? mapped.en : mapped.ko;
+};
+
+// 기본 컬럼 (기존 호환성 유지)
 export const detailDrawingColumns: ColumnDef<DetailDwgReceiptItem>[] = [
   {
     accessorKey: "RegisterSerialNo",
@@ -78,3 +112,88 @@ export const detailDrawingColumns: ColumnDef<DetailDwgReceiptItem>[] = [
   },
 ];
 
+// 다국어 지원 컬럼 생성 함수
+export function createDetailDrawingColumns(
+  lng: string,
+  // eslint-disable-next-line @typescript-eslint/no-explicit-any
+  t: any
+): ColumnDef<DetailDwgReceiptItem>[] {
+  return [
+    {
+      accessorKey: "RegisterSerialNo",
+      header: t("detailDrawing.columns.serialNo"),
+      minSize: 80,
+      cell: ({ row }) => {
+        return <div className="text-center">{row.getValue("RegisterSerialNo")}</div>;
+      },
+    },
+    {
+      accessorKey: "DrawingRevNo",
+      header: t("detailDrawing.columns.revNo"),
+      minSize: 100,
+      cell: ({ row }) => {
+        return <div className="font-medium">{row.getValue("DrawingRevNo")}</div>;
+      },
+    },
+    {
+      accessorKey: "Status",
+      header: t("detailDrawing.columns.status"),
+      minSize: 120,
+      cell: ({ row }) => {
+        return <div className="text-center">{row.getValue("Status")}</div>;
+      },
+    },
+    {
+      accessorKey: "CategoryENM",
+      header: t("detailDrawing.columns.category"),
+      minSize: 120,
+      cell: ({ row }) => {
+        const categoryENM = row.getValue("CategoryENM") as string;
+        const categoryNM = row.original.CategoryNM;
+        // 영어인 경우 ENM, 한국어인 경우 NM 사용
+        return <div>{lng === "en" ? (categoryENM || categoryNM) : (categoryNM || categoryENM)}</div>;
+      },
+    },
+    {
+      accessorKey: "DrawingUsageENM",
+      header: t("detailDrawing.columns.drawingUsage"),
+      minSize: 100,
+      cell: ({ row }) => {
+        // API의 ENM이 제대로 번역되지 않아 코드 값으로 직접 변환
+        const usageCode = row.getValue("DrawingUsageENM") as string | null;
+        const translated = translateDrawingUsage(usageCode, lng);
+        return <div>{translated || usageCode || row.original.DrawingUsageNM}</div>;
+      },
+    },
+    {
+      accessorKey: "RegisterKindENM",
+      header: t("detailDrawing.columns.registerKind"),
+      minSize: 180,
+      cell: ({ row }) => {
+        // API의 ENM이 제대로 번역되지 않아 코드 값으로 직접 변환
+        const kindCode = row.getValue("RegisterKindENM") as string | null;
+        const translated = translateRegisterKind(kindCode, lng);
+        return <div>{translated || kindCode || row.original.RegisterKindNM}</div>;
+      },
+    },
+    {
+      accessorKey: "CreateUserNM",
+      header: t("detailDrawing.columns.createdBy"),
+      minSize: 150,
+      cell: ({ row }) => {
+        const userENM = row.original.CreateUserENM;
+        const userNM = row.getValue("CreateUserNM") as string;
+        return <div>{lng === "en" ? (userENM || userNM) : (userNM || userENM)}</div>;
+      },
+    },
+    {
+      accessorKey: "CreateDt",
+      header: t("detailDrawing.columns.createdAt"),
+      minSize: 200,
+      cell: ({ row }) => {
+        const date = row.getValue("CreateDt") as string;
+        return <div className="text-sm text-muted-foreground">{formatDolceDateTime(date)}</div>;
+      },
+    },
+  ];
+}
-- 
cgit v1.2.3

