From a2e0785c8749c4d3766ecf3b70edfb7c2fe4df20 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Fri, 21 Nov 2025 09:44:33 +0000
Subject: (임수민) 준법 Red Flag 해제, 코멘트 수정
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../basic-contracts-detail-columns.tsx             | 74 +++++++++++++++++++++-
 1 file changed, 71 insertions(+), 3 deletions(-)

(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 b2c811fd..2ab39880 100644
--- a/lib/basic-contract/status-detail/basic-contracts-detail-columns.tsx
+++ b/lib/basic-contract/status-detail/basic-contracts-detail-columns.tsx
@@ -32,13 +32,21 @@ import { toast } from "sonner"
 import { useRouter } from "next/navigation"
 import { getComplianceResponseByBasicContractId } from "@/lib/compliance/services"
 
-interface GetColumnsProps {
+type RedFlagResolutionState = {
+  resolved: boolean
+  resolvedAt: Date | null
+  pendingApprovalId: string | null
+}
+
+export interface GetColumnsProps {
   setRowAction: React.Dispatch<React.SetStateAction<DataTableRowAction<BasicContractView> | null>>
   gtcData: Record<number, { gtcDocumentId: number | null; hasComments: boolean }>
   isLoadingGtcData: boolean
+  agreementCommentData: Record<number, { hasComments: boolean; commentCount: number }>
+  isLoadingAgreementCommentData: boolean
   redFlagData: Record<number, boolean>
   isLoadingRedFlagData: boolean
-  redFlagResolutionData: Record<number, { resolved: boolean; resolvedAt: Date | null }>
+  redFlagResolutionData: Record<number, RedFlagResolutionState>
   isLoadingRedFlagResolutionData: boolean
   isComplianceTemplate: boolean
   router: NextRouter;
@@ -61,6 +69,8 @@ export function getDetailColumns({
   setRowAction, 
   gtcData, 
   isLoadingGtcData,
+  agreementCommentData,
+  isLoadingAgreementCommentData,
   redFlagData,
   isLoadingRedFlagData,
   redFlagResolutionData,
@@ -134,7 +144,7 @@ export function getDetailColumns({
       }
 
       const handleResend = () => {
-        setRowAction({ type: "resend", row })
+        setRowAction({ type: "resend", row } as DataTableRowAction<BasicContractView>)
       }
 
       return (
@@ -256,6 +266,19 @@ export function getDetailColumns({
           </div>
         );
       }
+
+      if (resolution?.pendingApprovalId) {
+        return (
+          <div className="text-sm">
+            <Badge variant="secondary" className="font-medium">
+              해소요청 진행중
+            </Badge>
+            <div className="text-xs text-gray-500 mt-1">
+              결재 ID: {resolution.pendingApprovalId.slice(-6)}
+            </div>
+          </div>
+        );
+      }
       
       return (
         <div className="text-sm text-gray-400">-</div>
@@ -296,7 +319,10 @@ export function getDetailColumns({
         const name = row.getValue("vendorName") as string | null
         const contract = row.original
         const isGTCTemplate = contract.templateName?.includes('GTC')
+        const isComplianceContract = contract.templateName?.includes('준법')
         const contractGtcData = gtcData[contract.id]
+        const complianceNegotiation = agreementCommentData[contract.id]
+        const isNegotiationCompleted = !!contract.negotiationCompletedAt
 
         const handleOpenGTC = (e: React.MouseEvent) => {
           e.stopPropagation()
@@ -345,6 +371,48 @@ export function getDetailColumns({
                 )}
               </div>
             )}
+            {isComplianceContract && (
+              <div className="flex items-center gap-1">
+                {isLoadingAgreementCommentData ? (
+                  <Loader2 className="h-3 w-3 animate-spin text-gray-400" />
+                ) : isNegotiationCompleted ? (
+                  <Badge 
+                    variant="outline" 
+                    className="text-xs bg-green-50 text-green-700 border-green-200"
+                  >
+                    <MessageCircle className="h-3 w-3 mr-1" />
+                    협의 완료
+                  </Badge>
+                ) : complianceNegotiation?.hasComments ? (
+                  <Badge 
+                    variant="outline" 
+                    className="text-xs bg-orange-50 text-orange-700 border-orange-200"
+                    title={`협의 코멘트 ${complianceNegotiation.commentCount}개`}
+                    onClick={(event) => {
+                      event.stopPropagation();
+                      if (typeof window === "undefined") return;
+                      const params = new URLSearchParams();
+                      if (contract.templateId) {
+                        params.set("templateId", contract.templateId.toString());
+                      }
+                      if (contract.vendorId) {
+                        params.set("vendorId", contract.vendorId.toString());
+                      }
+                      if (contract.vendorName) {
+                        params.set("vendorName", contract.vendorName);
+                      }
+                      const query = params.toString();
+                      const complianceUrl = `/evcp/basic-contract/compliance-comments/${contract.id}${query ? `?${query}` : ""}`;
+                      window.open(complianceUrl, "_blank", "noopener,noreferrer");
+                    }}
+                    style={{ cursor: "pointer" }}
+                  >
+                    <MessageCircle className="h-3 w-3 mr-1" />
+                    협의 진행중 ({complianceNegotiation.commentCount})
+                  </Badge>
+                ) : null}
+              </div>
+            )}
           </div>
         )
       },
-- 
cgit v1.2.3

