"use client" import * as React from "react" import { type ColumnDef } from "@tanstack/react-table" import { Ellipsis, FileText, Download, Eye, MessageSquare, Upload } from "lucide-react" import { formatDate, formatBytes } from "@/lib/utils" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Checkbox } from "@/components/ui/checkbox" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu" import { Progress } from "@/components/ui/progress" import { RevisionDialog } from "./revision-dialog" import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header" import { AddRevisionDialog } from "./add-revision-dialog" interface GetAttachmentColumnsProps { onSelectAttachment: (attachment: any) => void } export function getAttachmentColumns({ onSelectAttachment }: GetAttachmentColumnsProps): ColumnDef[] { return [ /** ───────────── 체크박스 ───────────── */ { id: "select", header: ({ table }) => ( table.toggleAllPageRowsSelected(!!value)} aria-label="Select all" className="translate-y-0.5" /> ), cell: ({ row }) => ( row.toggleSelected(!!value)} aria-label="Select row" className="translate-y-0.5" /> ), size: 40, enableSorting: false, enableHiding: false, }, /** ───────────── 문서 정보 ───────────── */ { accessorKey: "serialNo", header: ({ column }) => ( ), cell: ({ row }) => ( ), size: 100, }, { accessorKey: "attachmentType", header: ({ column }) => ( ), cell: ({ row }) => { const type = row.getValue("attachmentType") as string return ( {type} ) }, size:100 }, { accessorKey: "originalFileName", header: ({ column }) => ( ), cell: ({ row }) => { const fileName = row.getValue("originalFileName") as string return (
{fileName}
) }, size:250 }, { id: "currentRevision", header: ({ column }) => ( ), cell: ({ row }) => ( ), size: 100, }, { accessorKey: "description", header: ({ column }) => ( ), cell: ({ row }) => { const description = row.getValue("description") as string return description ?
{description}
: - }, }, /** ───────────── 파일 정보 ───────────── */ // { // accessorKey: "fileSize", // header: ({ column }) => ( // // ), // cell: ({ row }) => { // const size = row.getValue("fileSize") as number // return size ? formatBytes(size) : "-" // }, // }, { accessorKey: "createdAt", header: ({ column }) => ( ), cell: ({ row }) => { const created = row.getValue("createdAt") as Date const updated = row.original.updatedAt as Date return (
{formatDate(created)}
{row.original.createdByName}
{updated && new Date(updated) > new Date(created) && (
수정: {formatDate(updated)}
)}
) }, maxSize:150 }, /** ───────────── 벤더 응답 현황 ───────────── */ { id: "vendorCount", header: ({ column }) => ( ), cell: ({ row }) => { const stats = row.original.responseStats return stats ? (
{stats.totalVendors}
활성: {stats.totalVendors - stats.waivedCount}
) : - }, }, { id: "responseStatus", header: ({ column }) => ( ), cell: ({ row }) => { const stats = row.original.responseStats return stats ? (
{stats.responseRate}%
응답: {stats.respondedCount} 대기: {stats.pendingCount} {stats.waivedCount > 0 && ( 면제: {stats.waivedCount} )}
) : - }, }, /** ───────────── 액션 ───────────── */ { id: "actions", enableHiding: false, cell: ({ row }) => { const [isAddRevisionOpen, setIsAddRevisionOpen] = React.useState(false) return ( <> onSelectAttachment(row.original)}> 벤더 응답 보기 미리보기 row.original.filePath && window.open(row.original.filePath, "_blank")} > 다운로드 setIsAddRevisionOpen(true)}> 새 리비전 추가 삭제 window.location.reload()} /> ) }, size: 40, }, ] }