From ba8cd44a0ed2c613a5f2cee06bfc9bd0f61f21c7 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Fri, 7 Nov 2025 08:39:04 +0000
Subject: (최겸) 입찰/견적 수정사항
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../list/biddings-table-toolbar-actions.tsx        | 64 ++++++++++++++++++----
 1 file changed, 54 insertions(+), 10 deletions(-)

(limited to 'lib/bidding/list/biddings-table-toolbar-actions.tsx')

diff --git a/lib/bidding/list/biddings-table-toolbar-actions.tsx b/lib/bidding/list/biddings-table-toolbar-actions.tsx
index 702396ae..0cb87b11 100644
--- a/lib/bidding/list/biddings-table-toolbar-actions.tsx
+++ b/lib/bidding/list/biddings-table-toolbar-actions.tsx
@@ -3,10 +3,9 @@
 import * as React from "react"
 import { type Table } from "@tanstack/react-table"
 import {
-  Plus, Send, Download, FileSpreadsheet
+  Send, Download, FileSpreadsheet
 } from "lucide-react"
 import { toast } from "sonner"
-import { useRouter } from "next/navigation"
 import { useSession } from "next-auth/react"
 import { exportTableToExcel } from "@/lib/export"
 import { Button } from "@/components/ui/button"
@@ -14,32 +13,74 @@ import {
   DropdownMenu,
   DropdownMenuContent,
   DropdownMenuItem,
-  DropdownMenuSeparator,
   DropdownMenuTrigger,
 } from "@/components/ui/dropdown-menu"
 import { BiddingListItem } from "@/db/schema"
-import { CreateBiddingDialog } from "./create-bidding-dialog"
+// import { CreateBiddingDialog } from "./create-bidding-dialog"
 import { TransmissionDialog } from "./biddings-transmission-dialog"
+import { BiddingCreateDialog } from "@/components/bidding/create/bidding-create-dialog"
+import { useForm } from "react-hook-form"
+import { zodResolver } from "@hookform/resolvers/zod"
+import { createBiddingSchema } from "@/lib/bidding/validation"
 
 interface BiddingsTableToolbarActionsProps {
   table: Table<BiddingListItem>
 }
 
 export function BiddingsTableToolbarActions({ table }: BiddingsTableToolbarActionsProps) {
-  const router = useRouter()
   const { data: session } = useSession()
   const [isExporting, setIsExporting] = React.useState(false)
   const [isTransmissionDialogOpen, setIsTransmissionDialogOpen] = React.useState(false)
 
   const userId = session?.user?.id ? Number(session.user.id) : 1
 
+  // 입찰 생성 폼
+  const form = useForm({
+    resolver: zodResolver(createBiddingSchema),
+    defaultValues: {
+      revision: 0,
+      title: '',
+      description: '',
+      content: '',
+      noticeType: 'standard' as const,
+      contractType: 'general' as const,
+      biddingType: 'equipment' as const,
+      awardCount: 'single' as const,
+      currency: 'KRW',
+      status: 'bidding_generated' as const,
+      bidPicName: '',
+      bidPicCode: '',
+      supplyPicName: '',
+      supplyPicCode: '',
+      requesterName: '',
+      attachments: [],
+      vendorAttachments: [],
+      hasSpecificationMeeting: false,
+      hasPrDocument: false,
+      isPublic: false,
+      isUrgent: false,
+      purchasingOrganization: '',
+      biddingConditions: {
+        paymentTerms: '',
+        taxConditions: 'V1',
+        incoterms: 'DAP',
+        incotermsOption: '',
+        contractDeliveryDate: '',
+        shippingPort: '',
+        destinationPort: '',
+        isPriceAdjustmentApplicable: false,
+        sparePartOptions: '',
+      },
+    },
+  })
+
   // 선택된 입찰들
   const selectedBiddings = React.useMemo(() => {
     return table
       .getFilteredSelectedRowModel()
       .rows
       .map(row => row.original)
-  }, [table.getFilteredSelectedRowModel().rows])
+  }, [table])
 
   // 업체선정이 완료된 입찰만 전송 가능
   const canTransmit = selectedBiddings.length === 1 && selectedBiddings[0].status === 'vendor_selected'
@@ -52,19 +93,22 @@ export function BiddingsTableToolbarActions({ table }: BiddingsTableToolbarActio
         excludeColumns: ["select", "actions"],
       })
       toast.success("입찰 목록이 성공적으로 내보내졌습니다.")
-    } catch (error) {
+    } catch {
       toast.error("내보내기 중 오류가 발생했습니다.")
     } finally {
       setIsExporting(false)
     }
   }
 
+
   return (
     <>
       <div className="flex items-center gap-2">
-        {/* 신규 생성 */}
-        <CreateBiddingDialog
-        />
+        {/* 신규입찰 생성 버튼 */}
+        <BiddingCreateDialog form={form} onSuccess={() => {
+          // 성공 시 테이블 새로고침 등 추가 작업
+          // window.location.reload()
+        }} />
 
         {/* 전송하기 (업체선정 완료된 입찰만) */}
         <Button
-- 
cgit v1.2.3

