'use client' import * as React from 'react' import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from '@/components/ui/dialog' import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { formatDate } from '@/lib/utils' import { History, Eye } from 'lucide-react' interface QuotationHistoryItem { id: string round: number submittedAt: Date totalAmount: number currency: string vsTargetPrice: number // 퍼센트 items: Array<{ itemCode: string itemName: string specification: string quantity: number unit: string unitPrice: number totalPrice: number deliveryDate: Date }> } interface QuotationHistoryDialogProps { open: boolean onOpenChange: (open: boolean) => void vendorName: string history: QuotationHistoryItem[] biddingCurrency: string targetPrice?: number } export function QuotationHistoryDialog({ open, onOpenChange, vendorName, history, biddingCurrency, targetPrice }: QuotationHistoryDialogProps) { const [selectedHistory, setSelectedHistory] = React.useState(null) const [detailDialogOpen, setDetailDialogOpen] = React.useState(false) const handleViewDetail = (historyItem: QuotationHistoryItem) => { setSelectedHistory(historyItem) setDetailDialogOpen(true) } const handleDetailDialogClose = () => { setDetailDialogOpen(false) setSelectedHistory(null) } return ( <> 견적 히스토리 - {vendorName} {vendorName} 업체의 제출한 견적 내역을 확인할 수 있습니다.
{history.length > 0 ? ( 차수 제출일시 견적금액 내정가대비 (%) 액션 {history.map((item) => ( {item.round}차 {formatDate(item.submittedAt, 'KR')} {item.totalAmount.toLocaleString()} {item.currency} {targetPrice && targetPrice > 0 ? ( {item.vsTargetPrice > 0 ? '+' : ''}{item.vsTargetPrice.toFixed(1)}% ) : ( '-' )} ))}
) : (
제출된 견적 내역이 없습니다.
)}
{/* 상세 다이얼로그 */} {selectedHistory && ( )} ) } // 견적 히스토리 상세 다이얼로그 interface QuotationHistoryDetailDialogProps { open: boolean onOpenChange: (open: boolean) => void vendorName: string historyItem: QuotationHistoryItem } function QuotationHistoryDetailDialog({ open, onOpenChange, vendorName, historyItem }: QuotationHistoryDetailDialogProps) { return ( 견적 상세 - {vendorName} ({historyItem.round}차) 제출일시: {formatDate(historyItem.submittedAt, 'KR')}
{/* 요약 정보 */}
{historyItem.totalAmount.toLocaleString()} {historyItem.currency}
{historyItem.items.length}개
{formatDate(historyItem.submittedAt, 'KR')}
{/* 품목 상세 테이블 */} 품목코드 품목명 규격 수량 단위 단가 금액 납기요청일 {historyItem.items.map((item, index) => ( {item.itemCode} {item.itemName} {item.specification || '-'} {item.quantity.toLocaleString()} {item.unit} {item.unitPrice.toLocaleString()} {historyItem.currency} {item.totalPrice.toLocaleString()} {historyItem.currency} {formatDate(item.deliveryDate, 'KR')} ))}
) }