diff options
Diffstat (limited to 'lib/bidding/selection')
| -rw-r--r-- | lib/bidding/selection/actions.ts | 49 | ||||
| -rw-r--r-- | lib/bidding/selection/biddings-selection-columns.tsx | 10 |
2 files changed, 42 insertions, 17 deletions
diff --git a/lib/bidding/selection/actions.ts b/lib/bidding/selection/actions.ts index e17e9292..16b2c083 100644 --- a/lib/bidding/selection/actions.ts +++ b/lib/bidding/selection/actions.ts @@ -127,7 +127,8 @@ export async function getQuotationHistory(biddingId: number, vendorId: number) { )) .limit(1) - if (!companyData.length || !companyData[0].quotationSnapshots) { + // 데이터 존재 여부 및 유효성 체크 + if (!companyData.length || !companyData[0]?.quotationSnapshots) { return { success: true, data: { @@ -136,7 +137,33 @@ export async function getQuotationHistory(biddingId: number, vendorId: number) { } } - const snapshots = companyData[0].quotationSnapshots as any[] + let snapshots = companyData[0].quotationSnapshots + + // quotationSnapshots가 JSONB 타입이므로 파싱이 필요할 수 있음 + if (typeof snapshots === 'string') { + try { + snapshots = JSON.parse(snapshots) + } catch (parseError) { + console.error('Failed to parse quotationSnapshots:', parseError) + return { + success: true, + data: { + history: [] + } + } + } + } + + // snapshots가 배열인지 확인 + if (!Array.isArray(snapshots)) { + console.error('quotationSnapshots is not an array:', typeof snapshots) + return { + success: true, + data: { + history: [] + } + } + } // PR 항목 정보 조회 (스냅샷의 prItemId로 매핑하기 위해) const prItemIds = snapshots.flatMap(snapshot => @@ -146,12 +173,11 @@ export async function getQuotationHistory(biddingId: number, vendorId: number) { const prItems = prItemIds.length > 0 ? await db .select({ id: prItemsForBidding.id, - itemCode: prItemsForBidding.itemCode, - itemName: prItemsForBidding.itemName, - specification: prItemsForBidding.specification, + itemNumber: prItemsForBidding.itemNumber, + itemInfo: prItemsForBidding.itemInfo, quantity: prItemsForBidding.quantity, - unit: prItemsForBidding.unit, - deliveryDate: prItemsForBidding.deliveryDate + quantityUnit: prItemsForBidding.quantityUnit, + requestedDeliveryDate: prItemsForBidding.requestedDeliveryDate }) .from(prItemsForBidding) .where(sql`${prItemsForBidding.id} IN ${prItemIds}`) : [] @@ -181,14 +207,13 @@ export async function getQuotationHistory(biddingId: number, vendorId: number) { const items = snapshot.items?.map((item: any) => { const prItem = prItemMap.get(item.prItemId) return { - itemCode: prItem?.itemCode || `ITEM${item.prItemId}`, - itemName: prItem?.itemName || '품목 정보 없음', - specification: prItem?.specification || item.technicalSpecification || '-', + itemCode: prItem?.itemNumber || `ITEM${item.prItemId}`, + itemName: prItem?.itemInfo || '품목 정보 없음', quantity: prItem?.quantity || 0, - unit: prItem?.unit || 'EA', + unit: prItem?.quantityUnit || 'EA', unitPrice: item.bidUnitPrice, totalPrice: item.bidAmount, - deliveryDate: item.proposedDeliveryDate ? new Date(item.proposedDeliveryDate) : prItem?.deliveryDate ? new Date(prItem.deliveryDate) : new Date() + deliveryDate: item.proposedDeliveryDate ? new Date(item.proposedDeliveryDate) : prItem?.requestedDeliveryDate ? new Date(prItem.requestedDeliveryDate) : new Date() } }) || [] diff --git a/lib/bidding/selection/biddings-selection-columns.tsx b/lib/bidding/selection/biddings-selection-columns.tsx index 0d1a8c9d..8351a0dd 100644 --- a/lib/bidding/selection/biddings-selection-columns.tsx +++ b/lib/bidding/selection/biddings-selection-columns.tsx @@ -5,7 +5,7 @@ import { type ColumnDef } from "@tanstack/react-table" import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import {
- Eye, Calendar, FileText, DollarSign, TrendingUp, TrendingDown
+ Eye, Calendar, FileText, DollarSign, TrendingUp, TrendingDown, MoreHorizontal
} from "lucide-react"
import {
Tooltip,
@@ -242,13 +242,13 @@ export function getBiddingsSelectionColumns({ setRowAction }: GetColumnsProps): // ═══════════════════════════════════════════════════════════════
{
id: "actions",
- header: "액션",
+ header: "작업",
cell: ({ row }) => (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" className="h-8 w-8 p-0">
<span className="sr-only">메뉴 열기</span>
- <FileText className="h-4 w-4" />
+ <MoreHorizontal className="h-4 w-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
@@ -256,7 +256,7 @@ export function getBiddingsSelectionColumns({ setRowAction }: GetColumnsProps): <Eye className="mr-2 h-4 w-4" />
상세보기
</DropdownMenuItem>
- {row.original.status === 'bidding_opened' && (
+ {/* {row.original.status === 'bidding_opened' && (
<>
<DropdownMenuSeparator />
<DropdownMenuItem onClick={() => setRowAction({ row, type: "close_bidding" })}>
@@ -264,7 +264,7 @@ export function getBiddingsSelectionColumns({ setRowAction }: GetColumnsProps): 입찰마감
</DropdownMenuItem>
</>
- )}
+ )} */}
{row.original.status === 'bidding_closed' && (
<>
<DropdownMenuSeparator />
|
