summaryrefslogtreecommitdiff
path: root/lib/tbe/table/tbe-table-columns.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tbe/table/tbe-table-columns.tsx')
-rw-r--r--lib/tbe/table/tbe-table-columns.tsx103
1 files changed, 99 insertions, 4 deletions
diff --git a/lib/tbe/table/tbe-table-columns.tsx b/lib/tbe/table/tbe-table-columns.tsx
index 3b62fe06..8f0de88c 100644
--- a/lib/tbe/table/tbe-table-columns.tsx
+++ b/lib/tbe/table/tbe-table-columns.tsx
@@ -37,6 +37,8 @@ interface GetColumnsProps {
router: NextRouter
openCommentSheet: (vendorId: number, rfqId: number) => void
openFilesDialog: (tbeId: number, vendorId: number, rfqId: number) => void
+ openVendorContactsDialog: (vendorId: number, vendor: VendorWithTbeFields) => void // 수정된 시그니처
+
}
@@ -47,7 +49,8 @@ export function getColumns({
setRowAction,
router,
openCommentSheet,
- openFilesDialog
+ openFilesDialog,
+ openVendorContactsDialog
}: GetColumnsProps): ColumnDef<VendorWithTbeFields>[] {
// ----------------------------------------------------------------
// 1) Select 컬럼 (체크박스)
@@ -105,6 +108,84 @@ export function getColumns({
cell: ({ row, getValue }) => {
// 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
@@ -222,13 +303,27 @@ const commentsColumn: ColumnDef<VendorWithTbeFields> = {
}
return (
- <Button variant="ghost" size="sm" className="h-8 w-8 p-0 group relative" onClick={handleClick}>
- <MessageSquare className="h-4 w-4" />
+ <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="absolute -top-1 -right-1 h-4 min-w-[1rem] text-[0.625rem] p-0 flex items-center justify-center">
+ <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>
)
},