"use client" import * as React from "react" import { type ColumnDef } from "@tanstack/react-table" import { Checkbox } from "@/components/ui/checkbox" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { MoreHorizontal } from "lucide-react" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" import { QuotationVendor } from "@/lib/bidding/detail/service" interface GetVendorColumnsProps { onEdit: (vendor: QuotationVendor) => void onViewPriceAdjustment?: (vendor: QuotationVendor) => void onViewItemDetails?: (vendor: QuotationVendor) => void onSendBidding?: (vendor: QuotationVendor) => void onUpdateParticipation?: (vendor: QuotationVendor, participated: boolean) => void biddingStatus?: string // 입찰 상태 정보 추가 } export function getBiddingDetailVendorColumns({ onEdit, onViewItemDetails, onSendBidding, onUpdateParticipation, biddingStatus }: GetVendorColumnsProps): ColumnDef[] { return [ { id: 'select', header: ({ table }) => ( table.toggleAllPageRowsSelected(!!value)} aria-label="모두 선택" /> ), cell: ({ row }) => ( row.toggleSelected(!!value)} aria-label="행 선택" /> ), enableSorting: false, enableHiding: false, }, { accessorKey: 'vendorName', header: '업체명', cell: ({ row }) => (
{row.original.vendorName}
), }, { accessorKey: 'vendorCode', header: '업체코드', cell: ({ row }) => (
{row.original.vendorCode}
), }, { accessorKey: 'quotationAmount', header: '견적금액', cell: ({ row }) => { const hasAmount = row.original.quotationAmount && Number(row.original.quotationAmount) > 0 return (
{hasAmount ? ( ) : ( - {row.original.currency} )}
) }, }, { accessorKey: 'biddingResult', header: '입찰결과', cell: ({ row }) => { const isWinner = row.original.isWinner if (isWinner === null || isWinner === undefined) { return
미정
} return ( {isWinner ? '낙찰' : '탈락'} ) }, }, { accessorKey: 'awardRatio', header: '발주비율', cell: ({ row }) => (
{row.original.awardRatio !== null ? `${row.original.awardRatio}%` : '-'}
), }, { accessorKey: 'isBiddingParticipated', header: '입찰참여', cell: ({ row }) => { const participated = row.original.isBiddingParticipated if (participated === null) { return 대기 } return ( {participated ? '응찰' : '미응찰'} ) }, }, { accessorKey: 'status', header: '상태', cell: ({ row }) => { const status = row.original.status const variant = status === 'selected' ? 'default' : status === 'submitted' ? 'secondary' : status === 'rejected' ? 'destructive' : 'outline' const label = status === 'selected' ? '선정' : status === 'submitted' ? '견적 제출' : status === 'rejected' ? '거절' : '대기' return {label} }, }, { accessorKey: 'submissionDate', header: '제출일', cell: ({ row }) => (
{row.original.submissionDate ? new Date(row.original.submissionDate).toLocaleDateString('ko-KR') : '-'}
), }, { id: 'actions', header: '작업', cell: ({ row }) => { const vendor = row.original return ( 작업 onEdit(vendor)} disabled={vendor.isBiddingParticipated !== true || biddingStatus === 'vendor_selected'} > 발주비율 산정 {vendor.isBiddingParticipated !== true && ( (입찰참여 필요) )} {biddingStatus === 'vendor_selected' && ( (낙찰 완료) )} {/* 입찰 참여여부 관리 */} {vendor.isBiddingParticipated === null && onUpdateParticipation && ( <> onUpdateParticipation(vendor, true)}> 응찰 설정 onUpdateParticipation(vendor, false)}> 미응찰 설정 )} {/* 입찰 보내기 (응찰한 업체만) */} {vendor.isBiddingParticipated === true && onSendBidding && ( <> onSendBidding(vendor)}> 입찰 보내기 )} ) }, }, ] }