summaryrefslogtreecommitdiff
path: root/lib/bidding/detail/table/bidding-detail-vendor-table.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bidding/detail/table/bidding-detail-vendor-table.tsx')
-rw-r--r--lib/bidding/detail/table/bidding-detail-vendor-table.tsx53
1 files changed, 48 insertions, 5 deletions
diff --git a/lib/bidding/detail/table/bidding-detail-vendor-table.tsx b/lib/bidding/detail/table/bidding-detail-vendor-table.tsx
index f2b05d4e..315c2aac 100644
--- a/lib/bidding/detail/table/bidding-detail-vendor-table.tsx
+++ b/lib/bidding/detail/table/bidding-detail-vendor-table.tsx
@@ -13,6 +13,7 @@ import { getBiddingDetailVendorColumns } from './bidding-detail-vendor-columns'
import { QuotationVendor, getPriceAdjustmentFormByBiddingCompanyId } from '@/lib/bidding/detail/service'
import { Bidding } from '@/db/schema'
import { PriceAdjustmentDialog } from '@/components/bidding/price-adjustment-dialog'
+import { QuotationHistoryDialog } from './quotation-history-dialog'
import { useToast } from '@/hooks/use-toast'
interface BiddingDetailVendorTableContentProps {
@@ -20,10 +21,10 @@ interface BiddingDetailVendorTableContentProps {
bidding: Bidding
vendors: QuotationVendor[]
onRefresh: () => void
- onOpenTargetPriceDialog: () => void
onOpenSelectionReasonDialog: () => void
onEdit?: (vendor: QuotationVendor) => void
onViewItemDetails?: (vendor: QuotationVendor) => void
+ onViewQuotationHistory?: (vendor: QuotationVendor) => void
}
const filterFields: DataTableFilterField<QuotationVendor>[] = [
@@ -82,9 +83,9 @@ export function BiddingDetailVendorTableContent({
bidding,
vendors,
onRefresh,
- onOpenTargetPriceDialog,
onEdit,
- onViewItemDetails
+ onViewItemDetails,
+ onViewQuotationHistory
}: BiddingDetailVendorTableContentProps) {
const { data: session } = useSession()
const { toast } = useToast()
@@ -96,6 +97,8 @@ export function BiddingDetailVendorTableContent({
const [isAwardDialogOpen, setIsAwardDialogOpen] = React.useState(false)
const [priceAdjustmentData, setPriceAdjustmentData] = React.useState<any>(null)
const [isPriceAdjustmentDialogOpen, setIsPriceAdjustmentDialogOpen] = React.useState(false)
+ const [quotationHistoryData, setQuotationHistoryData] = React.useState<any>(null)
+ const [isQuotationHistoryDialogOpen, setIsQuotationHistoryDialogOpen] = React.useState(false)
const handleEdit = (vendor: QuotationVendor) => {
setSelectedVendor(vendor)
@@ -126,14 +129,46 @@ export function BiddingDetailVendorTableContent({
}
}
+ const handleViewQuotationHistory = async (vendor: QuotationVendor) => {
+ try {
+ const { getQuotationHistory } = await import('@/lib/bidding/selection/actions')
+ const result = await getQuotationHistory(biddingId, vendor.vendorId)
+
+ if (result.success) {
+ setQuotationHistoryData({
+ vendorName: vendor.vendorName,
+ history: result.data.history,
+ biddingCurrency: bidding.currency || 'KRW',
+ targetPrice: bidding.targetPrice ? parseFloat(bidding.targetPrice.toString()) : undefined
+ })
+ setSelectedVendor(vendor)
+ setIsQuotationHistoryDialogOpen(true)
+ } else {
+ toast({
+ title: '오류',
+ description: result.error,
+ variant: 'destructive',
+ })
+ }
+ } catch (error) {
+ console.error('Failed to load quotation history:', error)
+ toast({
+ title: '오류',
+ description: '견적 히스토리를 불러오는데 실패했습니다.',
+ variant: 'destructive',
+ })
+ }
+ }
+
const columns = React.useMemo(
() => getBiddingDetailVendorColumns({
onEdit: onEdit || handleEdit,
onViewPriceAdjustment: handleViewPriceAdjustment,
onViewItemDetails: onViewItemDetails,
+ onViewQuotationHistory: onViewQuotationHistory || handleViewQuotationHistory,
biddingStatus: bidding.status
}),
- [onEdit, handleEdit, handleViewPriceAdjustment, onViewItemDetails, bidding.status]
+ [onEdit, handleEdit, handleViewPriceAdjustment, onViewItemDetails, onViewQuotationHistory, handleViewQuotationHistory, bidding.status]
)
const { table } = useDataTable({
@@ -163,7 +198,6 @@ export function BiddingDetailVendorTableContent({
biddingId={biddingId}
bidding={bidding}
userId={userId}
- onOpenTargetPriceDialog={onOpenTargetPriceDialog}
onOpenAwardDialog={() => setIsAwardDialogOpen(true)}
onSuccess={onRefresh}
/>
@@ -192,6 +226,15 @@ export function BiddingDetailVendorTableContent({
data={priceAdjustmentData}
vendorName={selectedVendor?.vendorName || ''}
/>
+
+ <QuotationHistoryDialog
+ open={isQuotationHistoryDialogOpen}
+ onOpenChange={setIsQuotationHistoryDialogOpen}
+ vendorName={quotationHistoryData?.vendorName || ''}
+ history={quotationHistoryData?.history || []}
+ biddingCurrency={quotationHistoryData?.biddingCurrency || 'KRW'}
+ targetPrice={quotationHistoryData?.targetPrice}
+ />
</>
)
}