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/tbe-table/tbe-table-columns.tsx | 99 +++++++++++++++++++++++++++-----
 1 file changed, 86 insertions(+), 13 deletions(-)

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

diff --git a/lib/rfqs/tbe-table/tbe-table-columns.tsx b/lib/rfqs/tbe-table/tbe-table-columns.tsx
index 0e9b7064..e8566831 100644
--- a/lib/rfqs/tbe-table/tbe-table-columns.tsx
+++ b/lib/rfqs/tbe-table/tbe-table-columns.tsx
@@ -11,21 +11,11 @@ import { formatDate } from "@/lib/utils"
 import { Badge } from "@/components/ui/badge"
 import { Button } from "@/components/ui/button"
 import { Checkbox } from "@/components/ui/checkbox"
-import {
-  DropdownMenu,
-  DropdownMenuContent,
-  DropdownMenuRadioGroup,
-  DropdownMenuRadioItem,
-  DropdownMenuSub,
-  DropdownMenuSubContent,
-  DropdownMenuSubTrigger,
-  DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu"
+
 import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header"
 import { useRouter } from "next/navigation"
 
 import {
-  VendorTbeColumnConfig,
   vendorTbeColumnsConfig,
   VendorWithTbeFields,
 } from "@/config/vendorTbeColumnsConfig"
@@ -39,6 +29,8 @@ interface GetColumnsProps {
   router: NextRouter
   openCommentSheet: (vendorId: number) => void
   openFilesDialog: (tbeId:number , vendorId: number) => void
+  openVendorContactsDialog: (vendorId: number, vendor: VendorWithTbeFields) => void // 수정된 시그니처
+
 }
 
 /**
@@ -46,9 +38,9 @@ interface GetColumnsProps {
  */
 export function getColumns({
   setRowAction,
-  router,
   openCommentSheet,
-  openFilesDialog
+  openFilesDialog,
+  openVendorContactsDialog
 }: GetColumnsProps): ColumnDef<VendorWithTbeFields>[] {
   // ----------------------------------------------------------------
   // 1) Select 컬럼 (체크박스)
@@ -107,6 +99,85 @@ 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 === "tbeResult") {
+          const vendor = row.original;
+          const tbeResult = vendor.tbeResult;
+          const filesCount = vendor.files?.length ?? 0;
+          
+          // Only show button or link if there are files
+          if (filesCount > 0) {
+            // Function to handle clicking on the result
+            const handleTbeResultClick = () => {
+              setRowAction({ row, type: "tbeResult" });
+            };
+            
+            if (!tbeResult) {
+              // No result yet, but files exist - show "결과 입력" button
+              return (
+                <Button
+                  variant="outline"
+                  size="sm"
+                  onClick={handleTbeResultClick}
+                >
+                  결과 입력
+                </Button>
+              );
+            } else {
+              // Result exists - show as a hyperlink
+              let badgeVariant: "default" | "outline" | "destructive" | "secondary" = "outline";
+              
+              // Set badge variant based on result
+              if (tbeResult === "pass") {
+                badgeVariant = "default";
+              } else if (tbeResult === "non-pass") {
+                badgeVariant = "destructive";
+              } else if (tbeResult === "conditional pass") {
+                badgeVariant = "secondary";
+              }
+              
+              return (
+                <Button
+                  variant="link"
+                  className="p-0 h-auto underline"
+                  onClick={handleTbeResultClick}
+                >
+                  <Badge variant={badgeVariant}>
+                    {tbeResult}
+                  </Badge>
+                </Button>
+              );
+            }
+          }
+          
+          // No files available, return empty cell
+          return null;
+        }
+
+
         if (cfg.id === "vendorStatus") {
           const statusVal = row.original.vendorStatus
           if (!statusVal) return null
@@ -131,6 +202,8 @@ export function getColumns({
           )
         }
 
+        
+
         // 예) TBE Updated (날짜)
         if (cfg.id === "tbeUpdated") {
           const dateVal = val as Date | undefined
-- 
cgit v1.2.3

