From a2bc455f654e011c53968b0d3a14389d7259847e Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Wed, 3 Sep 2025 10:35:57 +0000
Subject: (최겸) 구매 입찰 개발(벤더 응찰 개발 및 기본계약 요청 개발 필)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../detail/table/bidding-detail-vendor-table.tsx   | 46 ++++++++++++++++++++--
 1 file changed, 42 insertions(+), 4 deletions(-)

(limited to 'lib/bidding/detail/table/bidding-detail-vendor-table.tsx')

diff --git a/lib/bidding/detail/table/bidding-detail-vendor-table.tsx b/lib/bidding/detail/table/bidding-detail-vendor-table.tsx
index 7ad7056c..b1f0b08e 100644
--- a/lib/bidding/detail/table/bidding-detail-vendor-table.tsx
+++ b/lib/bidding/detail/table/bidding-detail-vendor-table.tsx
@@ -9,7 +9,9 @@ import { BiddingDetailVendorToolbarActions } from './bidding-detail-vendor-toolb
 import { BiddingDetailVendorCreateDialog } from './bidding-detail-vendor-create-dialog'
 import { BiddingDetailVendorEditDialog } from './bidding-detail-vendor-edit-dialog'
 import { getBiddingDetailVendorColumns } from './bidding-detail-vendor-columns'
-import { QuotationVendor } from '@/lib/bidding/detail/service'
+import { QuotationVendor, getPriceAdjustmentFormByBiddingCompanyId } from '@/lib/bidding/detail/service'
+import { Bidding } from '@/db/schema'
+import { PriceAdjustmentDialog } from '@/components/bidding/price-adjustment-dialog'
 import {
   deleteQuotationVendor,
   selectWinner
@@ -20,6 +22,7 @@ import { useTransition } from 'react'
 
 interface BiddingDetailVendorTableContentProps {
   biddingId: number
+  bidding: Bidding
   vendors: QuotationVendor[]
   onRefresh: () => void
   onOpenItemsDialog: () => void
@@ -83,6 +86,7 @@ const advancedFilterFields: DataTableAdvancedFilterField<QuotationVendor>[] = [
 
 export function BiddingDetailVendorTableContent({
   biddingId,
+  bidding,
   vendors,
   onRefresh,
   onOpenItemsDialog,
@@ -96,6 +100,8 @@ export function BiddingDetailVendorTableContent({
   const [isPending, startTransition] = useTransition()
   const [selectedVendor, setSelectedVendor] = React.useState<QuotationVendor | null>(null)
   const [isEditDialogOpen, setIsEditDialogOpen] = React.useState(false)
+  const [priceAdjustmentData, setPriceAdjustmentData] = React.useState<any>(null)
+  const [isPriceAdjustmentDialogOpen, setIsPriceAdjustmentDialogOpen] = React.useState(false)
 
   const handleDelete = (vendor: QuotationVendor) => {
     if (!confirm(`${vendor.vendorName} 업체를 삭제하시겠습니까?`)) return
@@ -170,13 +176,38 @@ export function BiddingDetailVendorTableContent({
     setIsEditDialogOpen(true)
   }
 
+  const handleViewPriceAdjustment = async (vendor: QuotationVendor) => {
+    try {
+      const priceAdjustmentForm = await getPriceAdjustmentFormByBiddingCompanyId(vendor.id)
+      if (priceAdjustmentForm) {
+        setPriceAdjustmentData(priceAdjustmentForm)
+        setSelectedVendor(vendor)
+        setIsPriceAdjustmentDialogOpen(true)
+      } else {
+        toast({
+          title: '연동제 정보 없음',
+          description: '해당 업체의 연동제 정보가 없습니다.',
+          variant: 'default',
+        })
+      }
+    } catch (error) {
+      console.error('Failed to load price adjustment form:', error)
+      toast({
+        title: '오류',
+        description: '연동제 정보를 불러오는데 실패했습니다.',
+        variant: 'destructive',
+      })
+    }
+  }
+
   const columns = React.useMemo(
     () => getBiddingDetailVendorColumns({
       onEdit: onEdit || handleEdit,
       onDelete: onDelete || handleDelete,
-      onSelectWinner: onSelectWinner || handleSelectWinner
+      onSelectWinner: onSelectWinner || handleSelectWinner,
+      onViewPriceAdjustment: handleViewPriceAdjustment
     }),
-    [onEdit, onDelete, onSelectWinner, handleEdit, handleDelete, handleSelectWinner]
+    [onEdit, onDelete, onSelectWinner, handleEdit, handleDelete, handleSelectWinner, handleViewPriceAdjustment]
   )
 
   const { table } = useDataTable({
@@ -205,10 +236,10 @@ export function BiddingDetailVendorTableContent({
           <BiddingDetailVendorToolbarActions
             table={table}
             biddingId={biddingId}
+            bidding={bidding}
             onOpenItemsDialog={onOpenItemsDialog}
             onOpenTargetPriceDialog={onOpenTargetPriceDialog}
             onOpenSelectionReasonDialog={onOpenSelectionReasonDialog}
-
             onSuccess={onRefresh}
           />
         </DataTableAdvancedToolbar>
@@ -220,6 +251,13 @@ export function BiddingDetailVendorTableContent({
         onOpenChange={setIsEditDialogOpen}
         onSuccess={onRefresh}
       />
+
+      <PriceAdjustmentDialog
+        open={isPriceAdjustmentDialogOpen}
+        onOpenChange={setIsPriceAdjustmentDialogOpen}
+        data={priceAdjustmentData}
+        vendorName={selectedVendor?.vendorName || ''}
+      />
     </>
   )
 }
-- 
cgit v1.2.3

