From 6c11fccc84f4c84fa72ee01f9caad9f76f35cea2 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Tue, 16 Sep 2025 09:20:58 +0000
Subject: (대표님, 최겸) 계약, 업로드 관련, 메뉴처리, 입찰, 프리쿼트,
 rfqLast관련, tbeLast관련
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../list/biddings-table-toolbar-actions.tsx        | 100 +++++++++++++--------
 1 file changed, 65 insertions(+), 35 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 2b7a9d7d..ed5538c6 100644
--- a/lib/bidding/list/biddings-table-toolbar-actions.tsx
+++ b/lib/bidding/list/biddings-table-toolbar-actions.tsx
@@ -2,12 +2,12 @@
 
 import * as React from "react"
 import { type Table } from "@tanstack/react-table"
-import { 
-  Plus, Send, Gavel, Download, FileSpreadsheet,
-  Eye, Clock, CheckCircle 
+import {
+  Plus, 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"
 import {
@@ -19,6 +19,7 @@ import {
 } from "@/components/ui/dropdown-menu"
 import { BiddingListItem } from "@/db/schema"
 import { CreateBiddingDialog } from "./create-bidding-dialog"
+import { TransmissionDialog } from "./biddings-transmission-dialog"
 
 interface BiddingsTableToolbarActionsProps {
   table: Table<BiddingListItem>
@@ -28,7 +29,11 @@ interface BiddingsTableToolbarActionsProps {
 
 export function BiddingsTableToolbarActions({ table, paymentTermsOptions, incotermsOptions }: 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 selectedBiddings = React.useMemo(() => {
@@ -38,6 +43,9 @@ export function BiddingsTableToolbarActions({ table, paymentTermsOptions, incote
       .map(row => row.original)
   }, [table.getFilteredSelectedRowModel().rows])
 
+  // 업체선정이 완료된 입찰만 전송 가능
+  const canTransmit = selectedBiddings.length === 1 && selectedBiddings[0].status === 'vendor_selected'
+
   const handleExport = async () => {
     try {
       setIsExporting(true)
@@ -54,47 +62,69 @@ export function BiddingsTableToolbarActions({ table, paymentTermsOptions, incote
   }
 
   return (
-    <div className="flex items-center gap-2">
-      {/* 신규 생성 */}
-    <CreateBiddingDialog
-      paymentTermsOptions={paymentTermsOptions}
-      incotermsOptions={incotermsOptions}
-    />
+    <>
+      <div className="flex items-center gap-2">
+        {/* 신규 생성 */}
+        <CreateBiddingDialog
+        paymentTermsOptions={paymentTermsOptions}
+        incotermsOptions={incotermsOptions}
+        />
 
-      {/* 개찰 (입찰 오픈) */}
-      {/* {openEligibleBiddings.length > 0 && (
-        <Button 
-          variant="outline" 
+        {/* 전송하기 (업체선정 완료된 입찰만) */}
+        <Button
+          variant="default"
           size="sm"
-          onClick={handleBiddingOpen}
+          onClick={() => setIsTransmissionDialogOpen(true)}
+          disabled={!canTransmit}
+          className="gap-2"
         >
-          <Gavel className="mr-2 h-4 w-4" />
-          개찰 ({openEligibleBiddings.length})
+          <Send className="size-4" aria-hidden="true" />
+          <span className="hidden sm:inline">전송하기</span>
         </Button>
-      )} */}
 
-      {/* Export */}
-      <DropdownMenu>
-        <DropdownMenuTrigger asChild>
+        {/* 개찰 (입찰 오픈) */}
+        {/* {openEligibleBiddings.length > 0 && (
           <Button
             variant="outline"
             size="sm"
-            className="gap-2"
-            disabled={isExporting}
+            onClick={handleBiddingOpen}
           >
-            <Download className="size-4" aria-hidden="true" />
-            <span className="hidden sm:inline">
-              {isExporting ? "내보내는 중..." : "Export"}
-            </span>
+            <Gavel className="mr-2 h-4 w-4" />
+            개찰 ({openEligibleBiddings.length})
           </Button>
-        </DropdownMenuTrigger>
-        <DropdownMenuContent align="end">
-          <DropdownMenuItem onClick={handleExport} disabled={isExporting}>
-            <FileSpreadsheet className="mr-2 size-4" />
-            <span>입찰 목록 내보내기</span>
-          </DropdownMenuItem>
-        </DropdownMenuContent>
-      </DropdownMenu>
-    </div>
+        )} */}
+
+        {/* Export */}
+        <DropdownMenu>
+          <DropdownMenuTrigger asChild>
+            <Button
+              variant="outline"
+              size="sm"
+              className="gap-2"
+              disabled={isExporting}
+            >
+              <Download className="size-4" aria-hidden="true" />
+              <span className="hidden sm:inline">
+                {isExporting ? "내보내는 중..." : "Export"}
+              </span>
+            </Button>
+          </DropdownMenuTrigger>
+          <DropdownMenuContent align="end">
+            <DropdownMenuItem onClick={handleExport} disabled={isExporting}>
+              <FileSpreadsheet className="mr-2 size-4" />
+              <span>입찰 목록 내보내기</span>
+            </DropdownMenuItem>
+          </DropdownMenuContent>
+        </DropdownMenu>
+      </div>
+
+      {/* 전송 다이얼로그 */}
+      <TransmissionDialog
+        open={isTransmissionDialogOpen}
+        onOpenChange={setIsTransmissionDialogOpen}
+        bidding={selectedBiddings[0]}
+        userId={userId}
+      />
+    </>
   )
 }
\ No newline at end of file
-- 
cgit v1.2.3

