From 18954df6565108a469fb1608ea3715dd9bb1b02d Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 1 Sep 2025 09:12:09 +0000
Subject: (대표님) 구매 기본계약, gtc 개발
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../basic-contracts-detail-columns.tsx             | 72 ++++++++++++++++++++--
 1 file changed, 66 insertions(+), 6 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 80c39d1e..9a140b27 100644
--- a/lib/basic-contract/status-detail/basic-contracts-detail-columns.tsx
+++ b/lib/basic-contract/status-detail/basic-contracts-detail-columns.tsx
@@ -1,4 +1,4 @@
-// basic-contracts-detail-columns.tsx
+// simple-basic-contracts-detail-columns.tsx
 "use client"
 
 import * as React from "react"
@@ -10,7 +10,16 @@ import { Badge } from "@/components/ui/badge"
 import { Checkbox } from "@/components/ui/checkbox"
 import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header"
 import { Button } from "@/components/ui/button"
-import { MoreHorizontal, Download, Eye, Mail, FileText, Clock } from "lucide-react"
+import { 
+    MoreHorizontal, 
+    Download, 
+    Eye, 
+    Mail, 
+    FileText, 
+    Clock, 
+    MessageCircle,
+    Loader2
+} from "lucide-react"
 import {
   DropdownMenu,
   DropdownMenuContent,
@@ -20,11 +29,18 @@ import {
 import { BasicContractView } from "@/db/schema"
 import { downloadFile, quickPreview } from "@/lib/file-download"
 import { toast } from "sonner"
+import { useRouter } from "next/navigation"
 
 interface GetColumnsProps {
   setRowAction: React.Dispatch<React.SetStateAction<DataTableRowAction<BasicContractView> | null>>
+  gtcData: Record<number, { gtcDocumentId: number | null; hasComments: boolean }>
+  isLoadingGtcData: boolean
+  router: NextRouter;
 }
 
+type NextRouter = ReturnType<typeof useRouter>;
+
+
 const CONTRACT_STATUS_CONFIG = {
   PENDING: { label: "발송완료", color: "gray" },
   VENDOR_SIGNED: { label: "협력업체 서명완료", color: "blue" },
@@ -35,7 +51,12 @@ const CONTRACT_STATUS_CONFIG = {
   REJECTED: { label: "거절됨", color: "red" },
 } as const
 
-export function getDetailColumns({ setRowAction }: GetColumnsProps): ColumnDef<BasicContractView>[] {
+export function getDetailColumns({ 
+  setRowAction, 
+  gtcData, 
+  isLoadingGtcData,
+  router 
+}: GetColumnsProps): ColumnDef<BasicContractView>[] {
   
   const selectColumn: ColumnDef<BasicContractView> = {
     id: "select",
@@ -163,7 +184,7 @@ export function getDetailColumns({ setRowAction }: GetColumnsProps): ColumnDef<B
       minSize: 120,
     },
     
-    // 업체명
+    // 업체명 (GTC 정보 포함)
     {
       accessorKey: "vendorName",
       header: ({ column }) => (
@@ -171,11 +192,51 @@ export function getDetailColumns({ setRowAction }: GetColumnsProps): ColumnDef<B
       ),
       cell: ({ row }) => {
         const name = row.getValue("vendorName") as string | null
+        const contract = row.original
+        const isGTCTemplate = contract.templateName?.includes('GTC')
+        const contractGtcData = gtcData[contract.id]
+
+        const handleOpenGTC = (e: React.MouseEvent) => {
+          e.stopPropagation()
+          if (contractGtcData?.gtcDocumentId) {
+            const gtcUrl = `/evcp/basic-contract/vendor-gtc/${contractGtcData.gtcDocumentId}?vendorId=${contract.vendorId}&vendorName=${encodeURIComponent(contract.vendorName || '')}&contractId=${contract.id}&templateId=${contract.templateId}`
+            window.open(gtcUrl, '_blank')
+          }
+        }
+
         return (
+          <div className="flex items-center gap-2">
             <div className="font-medium">{name || "-"}</div>
+            {isGTCTemplate && (
+              <div className="flex items-center gap-1">
+                {isLoadingGtcData ? (
+                  <Loader2 className="h-3 w-3 animate-spin text-gray-400" />
+                ) : contractGtcData ? (
+                  <div className="flex items-center gap-1">
+                    {contractGtcData.hasComments && (
+                      <Badge 
+                        variant="secondary" 
+                        className="text-xs bg-orange-100 text-orange-700 cursor-pointer hover:bg-orange-200"
+                        title={`GTC Document ID: ${contractGtcData.gtcDocumentId} - 클릭하여 협의이력 보기`}
+                        onClick={handleOpenGTC}
+                      >
+                        <MessageCircle className="h-3 w-3 mr-1" />
+                        협의이력
+                      </Badge>
+                    )}
+                    
+                  </div>
+                ) : (
+                  <Badge variant="secondary" className="text-xs">
+                    GTC
+                  </Badge>
+                )}
+              </div>
+            )}
+          </div>
         )
       },
-      minSize: 180,
+      minSize: 250,
     },
     
     // 진행상태
@@ -349,7 +410,6 @@ export function getDetailColumns({ setRowAction }: GetColumnsProps): ColumnDef<B
       minSize: 120,
     },
 
-
     // 서명된 파일
     {
         accessorKey: "signedFileName",
-- 
cgit v1.2.3

