From ef4c533ebacc2cdc97e518f30e9a9350004fcdfb Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 28 Apr 2025 02:13:30 +0000
Subject: ~20250428 작업사항
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/rfqs/cbe-table/cbe-table-columns.tsx | 92 +++++++++++++++++++-------------
 1 file changed, 55 insertions(+), 37 deletions(-)

(limited to 'lib/rfqs/cbe-table/cbe-table-columns.tsx')

diff --git a/lib/rfqs/cbe-table/cbe-table-columns.tsx b/lib/rfqs/cbe-table/cbe-table-columns.tsx
index 325b0465..bc16496f 100644
--- a/lib/rfqs/cbe-table/cbe-table-columns.tsx
+++ b/lib/rfqs/cbe-table/cbe-table-columns.tsx
@@ -34,8 +34,9 @@ interface GetColumnsProps {
     React.SetStateAction<DataTableRowAction<VendorWithCbeFields> | null>
   >
   router: NextRouter
-  openCommentSheet: (vendorId: number) => void
-  openFilesDialog: (cbeId:number , vendorId: number) => void
+  openCommentSheet: (responseId: number) => void
+  openVendorContactsDialog: (vendorId: number, vendor: VendorWithCbeFields) => void // 수정된 시그니처
+
 }
 
 /**
@@ -45,7 +46,7 @@ export function getColumns({
   setRowAction,
   router,
   openCommentSheet,
-  openFilesDialog
+  openVendorContactsDialog
 }: GetColumnsProps): ColumnDef<VendorWithCbeFields>[] {
   // ----------------------------------------------------------------
   // 1) Select 컬럼 (체크박스)
@@ -104,6 +105,30 @@ export function getColumns({
         // 1) 필드값 가져오기
         const val = getValue()
 
+        if (cfg.id === "vendorName") {
+          const vendor = row.original;
+          const vendorId = vendor.vendorId;
+          
+          // 협력업체 이름을 클릭할 수 있는 버튼으로 렌더링
+          const handleVendorNameClick = () => {
+            if (vendorId) {
+              openVendorContactsDialog(vendorId, vendor); // vendor 전체 객체 전달
+            } else {
+              toast.error("협력업체 ID를 찾을 수 없습니다.");
+            }
+          };
+          
+          return (
+            <Button
+              variant="link"
+              className="p-0 h-auto text-left font-normal justify-start hover:underline"
+              onClick={handleVendorNameClick}
+            >
+              {val as string}
+            </Button>
+          );
+        }
+
         if (cfg.id === "vendorStatus") {
           const statusVal = row.original.vendorStatus
           if (!statusVal) return null
@@ -116,8 +141,8 @@ export function getColumns({
         }
 
 
-        if (cfg.id === "rfqVendorStatus") {
-          const statusVal = row.original.rfqVendorStatus
+        if (cfg.id === "responseStatus") {
+          const statusVal = row.original.responseStatus
           if (!statusVal) return null
           // const Icon = getStatusIcon(statusVal)
           const variant = statusVal ==="INVITED"?"default" :statusVal ==="DECLINED"?"destructive":statusVal ==="ACCEPTED"?"secondary":"outline"
@@ -128,8 +153,8 @@ export function getColumns({
           )
         }
 
-        // 예) TBE Updated (날짜)
-        if (cfg.id === "cbeUpdated") {
+        // 예) CBE Updated (날짜)
+        if (cfg.id === "respondedAt"  ) {
           const dateVal = val as Date | undefined
           if (!dateVal) return null
           return formatDate(dateVal)
@@ -172,39 +197,32 @@ const commentsColumn: ColumnDef<VendorWithCbeFields> = {
     function handleClick() {
       // rowAction + openCommentSheet
       setRowAction({ row, type: "comments" })
-      openCommentSheet(vendor.cbeId ?? 0)
+      openCommentSheet(vendor.responseId ?? 0)
     }
 
     return (
-      <div className="flex items-center justify-center">
-        <Button
-          variant="ghost"
-          size="sm"
-          className="h-8 w-8 p-0 group relative"
-          onClick={handleClick}
-          aria-label={commCount > 0 ? `View ${commCount} comments` : "Add comment"}
-        >
-          <div className="flex items-center justify-center relative">
-            {commCount > 0 ? (
-              <>
-                <MessageSquare className="h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors" />
-                <Badge 
-                  variant="secondary" 
-                  className="absolute -top-2 -right-2 h-4 min-w-4 text-xs px-1 flex items-center justify-center"
-                >
-                  {commCount}
-                </Badge>
-              </>
-            ) : (
-              <MessageSquare className="h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors" />
-            )}
-          </div>
-          <span className="sr-only">{commCount > 0 ? `${commCount} Comments` : "Add Comment"}</span>
-        </Button>
-        {/* <span className="ml-2 text-sm text-muted-foreground hover:text-foreground transition-colors cursor-pointer" onClick={handleClick}>
-          {commCount > 0 ? `${commCount} Comments` : "Add Comment"}
-        </span> */}
-      </div>
+      <Button
+        variant="ghost"
+        size="sm"
+        className="relative h-8 w-8 p-0 group"
+        onClick={handleClick}
+        aria-label={
+          commCount > 0 ? `View ${commCount} comments` : "No comments"
+        }
+      >
+        <MessageSquare className="h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors" />
+        {commCount > 0 && (
+          <Badge
+            variant="secondary"
+            className="pointer-events-none absolute -top-1 -right-1 h-4 min-w-[1rem] p-0 text-[0.625rem] leading-none flex items-center justify-center"
+          >
+            {commCount}
+          </Badge>
+        )}
+        <span className="sr-only">
+          {commCount > 0 ? `${commCount} Comments` : "No Comments"}
+        </span>
+      </Button>
     )
   },
   enableSorting: false,
-- 
cgit v1.2.3

