From f95fbb0719c5754360472d066b0bbed4bda6a40a Mon Sep 17 00:00:00 2001
From: 0-Zz-ang <s1998319@gmail.com>
Date: Thu, 20 Nov 2025 17:39:10 +0900
Subject: (박서영)준법설문조사 redFlag관련사항수정
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../basic-contracts-detail-columns.tsx             | 56 +++++++++++++++++++++-
 1 file changed, 55 insertions(+), 1 deletion(-)

(limited to 'lib/basic-contract/status-detail/basic-contracts-detail-columns.tsx')

diff --git a/lib/basic-contract/status-detail/basic-contracts-detail-columns.tsx b/lib/basic-contract/status-detail/basic-contracts-detail-columns.tsx
index 5a875541..c872aede 100644
--- a/lib/basic-contract/status-detail/basic-contracts-detail-columns.tsx
+++ b/lib/basic-contract/status-detail/basic-contracts-detail-columns.tsx
@@ -36,6 +36,9 @@ interface GetColumnsProps {
   setRowAction: React.Dispatch<React.SetStateAction<DataTableRowAction<BasicContractView> | null>>
   gtcData: Record<number, { gtcDocumentId: number | null; hasComments: boolean }>
   isLoadingGtcData: boolean
+  redFlagData: Record<number, boolean>
+  isLoadingRedFlagData: boolean
+  isComplianceTemplate: boolean
   router: NextRouter;
 }
 
@@ -56,6 +59,9 @@ export function getDetailColumns({
   setRowAction, 
   gtcData, 
   isLoadingGtcData,
+  redFlagData,
+  isLoadingRedFlagData,
+  isComplianceTemplate,
   router 
 }: GetColumnsProps): ColumnDef<BasicContractView>[] {
   
@@ -184,7 +190,41 @@ export function getDetailColumns({
     maxSize: 80,
   }
 
-  return [
+  // Red Flag 발생여부 컬럼 (준법서약 템플릿만)
+  const redFlagColumn: ColumnDef<BasicContractView> = {
+    id: "redFlag",
+    header: ({ column }) => (
+      <DataTableColumnHeaderSimple column={column} title="Red Flag" />
+    ),
+    cell: ({ row }) => {
+      const contract = row.original;
+      const contractId = contract.id;
+      
+      // 로딩 중이면 로딩 표시
+      if (isLoadingRedFlagData) {
+        return <Loader2 className="h-4 w-4 animate-spin text-muted-foreground" />;
+      }
+      
+      const hasRedFlag = redFlagData[contractId] || false;
+      
+      if (hasRedFlag) {
+        return (
+          <Badge variant="destructive" className="font-medium">
+            Red Flag
+          </Badge>
+        );
+      }
+      
+      return (
+        <div className="text-sm text-gray-400">-</div>
+      );
+    },
+    minSize: 120,
+    enableHiding: false,
+  }
+
+  // 기본 컬럼 배열
+  const baseColumns: ColumnDef<BasicContractView>[] = [
     selectColumn,
     
     // 업체 코드
@@ -513,4 +553,18 @@ export function getDetailColumns({
          
     actionsColumn,
   ]
+
+  // 준법서약 템플릿인 경우 Red Flag 컬럼을 법무검토 상태 뒤에 추가
+  if (isComplianceTemplate) {
+    const legalReviewStatusIndex = baseColumns.findIndex((col) => {
+      // eslint-disable-next-line @typescript-eslint/no-explicit-any
+      return (col as any).accessorKey === 'legalReviewStatus'
+    })
+    
+    if (legalReviewStatusIndex !== -1) {
+      baseColumns.splice(legalReviewStatusIndex + 1, 0, redFlagColumn)
+    }
+  }
+
+  return baseColumns
 }
\ No newline at end of file
-- 
cgit v1.2.3

