summaryrefslogtreecommitdiff
path: root/lib/bidding/detail/table
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-09-22 08:56:13 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-09-22 08:56:13 +0000
commite4bd037d158513e45373ad9e1ef13f71af12162a (patch)
treebf4a174ea33a2fb1173dc46c41f27e50df3310dd /lib/bidding/detail/table
parent06d4753d61a803e2f8447bc3167dced3434107d4 (diff)
(최겸) 구매 입찰 중량별 구분 삭제, itb requestTitle 컬럼 maxSize 변경
Diffstat (limited to 'lib/bidding/detail/table')
-rw-r--r--lib/bidding/detail/table/bidding-vendor-prices-dialog.tsx88
1 files changed, 20 insertions, 68 deletions
diff --git a/lib/bidding/detail/table/bidding-vendor-prices-dialog.tsx b/lib/bidding/detail/table/bidding-vendor-prices-dialog.tsx
index c12ac1df..dfcef812 100644
--- a/lib/bidding/detail/table/bidding-vendor-prices-dialog.tsx
+++ b/lib/bidding/detail/table/bidding-vendor-prices-dialog.tsx
@@ -8,7 +8,6 @@ import {
DialogHeader,
DialogTitle,
} from '@/components/ui/dialog'
-import { Button } from '@/components/ui/button'
import { Badge } from '@/components/ui/badge'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import {
@@ -21,8 +20,6 @@ import {
} from '@/components/ui/table'
import {
DollarSign,
- Package,
- Scale,
Building,
TrendingDown,
TrendingUp
@@ -41,8 +38,6 @@ interface VendorPrice {
itemName: string
quantity: number
quantityUnit: string
- weight: number | null
- weightUnit: string | null
unitPrice: number
amount: number
proposedDeliveryDate?: string
@@ -71,16 +66,8 @@ export function BiddingVendorPricesDialog({
const { toast } = useToast()
const [vendorPrices, setVendorPrices] = React.useState<VendorPrice[]>([])
const [isLoading, setIsLoading] = React.useState(false)
- const [viewMode, setViewMode] = React.useState<'quantity' | 'weight'>('quantity')
- // 다이얼로그가 열릴 때 데이터 로드
- React.useEffect(() => {
- if (open) {
- loadVendorPrices()
- }
- }, [open, biddingId])
-
- const loadVendorPrices = async () => {
+ const loadVendorPrices = React.useCallback(async () => {
setIsLoading(true)
try {
const data = await getVendorPricesForBidding(biddingId)
@@ -95,7 +82,15 @@ export function BiddingVendorPricesDialog({
} finally {
setIsLoading(false)
}
- }
+ }, [biddingId, toast])
+
+ // 다이얼로그가 열릴 때 데이터 로드
+ React.useEffect(() => {
+ if (open) {
+ loadVendorPrices()
+ }
+ }, [open, loadVendorPrices])
+
// 금액 포맷팅
const formatCurrency = (amount: number) => {
@@ -107,22 +102,14 @@ export function BiddingVendorPricesDialog({
}).format(amount)
}
- // 수량/중량 포맷팅
+ // 수량 포맷팅
const formatQuantity = (quantity: number, unit: string) => {
return `${quantity.toLocaleString()} ${unit}`
}
- const formatWeight = (weight: number | null, unit: string | null) => {
- if (!weight || !unit) return '-'
- return `${weight.toLocaleString()} ${unit}`
- }
-
// 최저가 계산
- const getLowestPrice = (itemPrices: VendorPrice['itemPrices'], field: 'quantity' | 'weight') => {
- const validPrices = itemPrices.filter(item => {
- if (field === 'quantity') return item.quantity > 0
- return item.weight && item.weight > 0
- })
+ const getLowestPrice = (itemPrices: VendorPrice['itemPrices']) => {
+ const validPrices = itemPrices.filter(item => item.quantity > 0)
if (validPrices.length === 0) return null
@@ -131,11 +118,8 @@ export function BiddingVendorPricesDialog({
}
// 최고가 계산
- const getHighestPrice = (itemPrices: VendorPrice['itemPrices'], field: 'quantity' | 'weight') => {
- const validPrices = itemPrices.filter(item => {
- if (field === 'quantity') return item.quantity > 0
- return item.weight && item.weight > 0
- })
+ const getHighestPrice = (itemPrices: VendorPrice['itemPrices']) => {
+ const validPrices = itemPrices.filter(item => item.quantity > 0)
if (validPrices.length === 0) return null
@@ -205,30 +189,6 @@ export function BiddingVendorPricesDialog({
</Card>
</div>
- {/* 뷰 모드 토글 */}
- <div className="flex items-center gap-2">
- <span className="text-sm font-medium">보기 방식:</span>
- <div className="flex bg-muted rounded-lg p-1">
- <Button
- variant={viewMode === 'quantity' ? 'default' : 'ghost'}
- size="sm"
- onClick={() => setViewMode('quantity')}
- className="flex items-center gap-2"
- >
- <Package className="w-4 h-4" />
- 수량별
- </Button>
- <Button
- variant={viewMode === 'weight' ? 'default' : 'ghost'}
- size="sm"
- onClick={() => setViewMode('weight')}
- className="flex items-center gap-2"
- >
- <Scale className="w-4 h-4" />
- 중량별
- </Button>
- </div>
- </div>
{isLoading ? (
<div className="flex items-center justify-center py-12">
@@ -262,9 +222,7 @@ export function BiddingVendorPricesDialog({
<TableHeader>
<TableRow>
<TableHead>품목명</TableHead>
- <TableHead className="text-right">
- {viewMode === 'quantity' ? '수량' : '중량'}
- </TableHead>
+ <TableHead className="text-right">수량</TableHead>
<TableHead className="text-right">단가</TableHead>
<TableHead className="text-right">금액</TableHead>
<TableHead className="text-center">가격대</TableHead>
@@ -273,13 +231,10 @@ export function BiddingVendorPricesDialog({
</TableHeader>
<TableBody>
{vendor.itemPrices
- .filter(item => {
- if (viewMode === 'quantity') return item.quantity > 0
- return item.weight && item.weight > 0
- })
+ .filter(item => item.quantity > 0)
.map((item, index) => {
- const lowestPrice = getLowestPrice(vendor.itemPrices, viewMode)
- const highestPrice = getHighestPrice(vendor.itemPrices, viewMode)
+ const lowestPrice = getLowestPrice(vendor.itemPrices)
+ const highestPrice = getHighestPrice(vendor.itemPrices)
const isLowest = item.unitPrice === lowestPrice
const isHighest = item.unitPrice === highestPrice
@@ -289,10 +244,7 @@ export function BiddingVendorPricesDialog({
{item.itemName}
</TableCell>
<TableCell className="text-right font-mono">
- {viewMode === 'quantity'
- ? formatQuantity(item.quantity, item.quantityUnit)
- : formatWeight(item.weight, item.weightUnit) // totalWeight를 weight로 매핑했으므로 사용 가능
- }
+ {formatQuantity(item.quantity, item.quantityUnit)}
</TableCell>
<TableCell className="text-right font-mono">
{formatCurrency(item.unitPrice)}