From 37611339fea096e47aaa42311a13a6313b4200db Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 2 Jun 2025 02:27:28 +0000
Subject: (대표님) 20250602 오전 작업사항 (코드프리징)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 components/form-data/form-data-table-columns.tsx | 47 +++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 2 deletions(-)

(limited to 'components/form-data/form-data-table-columns.tsx')

diff --git a/components/form-data/form-data-table-columns.tsx b/components/form-data/form-data-table-columns.tsx
index bba2a208..3749fe02 100644
--- a/components/form-data/form-data-table-columns.tsx
+++ b/components/form-data/form-data-table-columns.tsx
@@ -2,6 +2,7 @@ import type { ColumnDef, Row } from "@tanstack/react-table";
 import { ClientDataTableColumnHeaderSimple } from "../client-data-table/data-table-column-simple-header";
 import { Button } from "@/components/ui/button";
 import { Checkbox } from "@/components/ui/checkbox";
+import { Badge } from "@/components/ui/badge"; // Badge import 추가
 import { Ellipsis } from "lucide-react";
 import { formatDate } from "@/lib/utils";
 import {
@@ -60,6 +61,31 @@ interface GetColumnsProps<TData> {
   // editableFieldsMap 제거됨
 }
 
+/**
+ * status 값에 따라 Badge variant를 결정하는 헬퍼 함수
+ */
+function getStatusBadgeVariant(status: string): "default" | "secondary" | "destructive" | "outline" {
+  const statusStr = String(status).toLowerCase();
+  
+  switch (statusStr) {
+    case 'NEW':
+    case 'New':
+    // case 'approved':
+      return 'default'; // 초록색 계열
+    case 'Updated or Modified':
+    // case 'in progress':
+    // case 'processing':
+      return 'secondary'; // 노란색 계열
+    case 'inactive':
+    case 'rejected':
+    case 'failed':
+    case 'cancelled':
+      return 'destructive'; // 빨간색 계열
+    default:
+      return 'outline'; // 기본 회색 계열
+  }
+}
+
 /**
  * getColumns 함수
  * 1) columnsJSON 배열을 순회하면서 accessorKey / header / cell 등을 설정
@@ -122,8 +148,7 @@ export function getColumns<TData extends object>({
     ),
     enableSorting: false,
     enableHiding: false,
-    enablePinning: true, // ← 이 줄 추가
-
+    enablePinning: true,
     size: 40,
   };
   columns.push(selectColumn);
@@ -160,6 +185,24 @@ export function getColumns<TData extends object>({
       // 툴팁 메시지 설정 (SHI 필드만)
       const tooltipMessage = isReadOnly ? "SHI 전용 필드입니다" : "";
 
+      // status 컬럼인 경우 Badge 적용
+      if (col.key === "status") {
+        const statusValue = String(cellValue ?? "");
+        const badgeVariant = getStatusBadgeVariant(statusValue);
+        
+        return (
+          <div 
+            className={readOnlyClass} 
+            style={cellStyle}
+            title={tooltipMessage}
+          >
+            <Badge variant={badgeVariant}>
+              {statusValue}
+            </Badge>
+          </div>
+        );
+      }
+
       // 데이터 타입별 처리
       switch (col.type) {
         case "NUMBER":
-- 
cgit v1.2.3

