'use client' import * as React from 'react' import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog' import { DataTable } from '@/components/data-table/data-table' import { ColumnDef } from '@tanstack/react-table' import { Building2, User, Mail, Phone, Calendar, BadgeCheck } from 'lucide-react' import { formatDate } from '@/lib/utils' import { Badge } from '@/components/ui/badge' interface ParticipantCompany { id: number biddingId: number companyId: number | null vendorName: string vendorCode: string contactPerson: string | null contactEmail: string | null contactPhone: string | null invitationStatus: string updatedAt: Date | null } interface BiddingParticipantsDialogProps { open: boolean onOpenChange: (open: boolean) => void biddingId: number | null participantType: 'expected' | 'participated' | 'declined' | 'pending' | null companies: ParticipantCompany[] } const invitationStatusLabels: Record = { invited: { label: '초대됨', variant: 'outline' }, accepted: { label: '참여확정', variant: 'default' }, declined: { label: '포기', variant: 'destructive' }, pending: { label: '미제출', variant: 'secondary' }, submitted: { label: '제출완료', variant: 'default' }, } const participantTypeLabels: Record = { expected: '참여예정협력사', participated: '참여협력사', declined: '포기협력사', pending: '미제출협력사', } export function BiddingParticipantsDialog({ open, onOpenChange, biddingId, participantType, companies, }: BiddingParticipantsDialogProps) { const columns = React.useMemo[]>( () => [ { id: 'vendorCode', accessorKey: 'vendorCode', header: '협력사코드', cell: ({ row }) => (
{row.original.vendorCode}
), size: 120, }, { id: 'vendorName', accessorKey: 'vendorName', header: '협력사명', cell: ({ row }) => (
{row.original.vendorName}
), size: 200, }, { id: 'invitationStatus', accessorKey: 'invitationStatus', header: '구분', cell: ({ row }) => { const status = row.original.invitationStatus const statusInfo = invitationStatusLabels[status] || { label: status, variant: 'outline' as const } return ( {statusInfo.label} ) }, size: 100, }, { id: 'updatedAt', accessorKey: 'updatedAt', header: '응찰/포기일시', cell: ({ row }) => (
{row.original.updatedAt ? formatDate(row.original.updatedAt) : '-'}
), size: 150, }, { id: 'contactPerson', accessorKey: 'contactPerson', header: '협력사 담당자', cell: ({ row }) => (
{row.original.contactPerson || '-'}
), size: 120, }, { id: 'contactEmail', accessorKey: 'contactEmail', header: '담당자 이메일', cell: ({ row }) => (
{row.original.contactEmail || '-'}
), size: 200, }, { id: 'contactPhone', accessorKey: 'contactPhone', header: '담당자 전화번호', cell: ({ row }) => (
{row.original.contactPhone || '-'}
), size: 150, }, ], [] ) const table = React.useMemo( () => ({ data: companies, columns, pageCount: 1, }), [companies, columns] ) return ( {'협력사 목록'} {' '} ({companies.length}개)
{columns.map((column) => ( ))} {companies.length === 0 ? ( ) : ( companies.map((company) => ( {columns.map((column) => ( ))} )) )}
{typeof column.header === 'function' ? column.header({} as any) : column.header}
협력사가 없습니다.
{column.cell ? column.cell({ row: { original: company } } as any) : (company as any)[column.accessorKey as string]}
) }