From 6c11fccc84f4c84fa72ee01f9caad9f76f35cea2 Mon Sep 17 00:00:00 2001 From: dujinkim 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 ++++++++----- lib/bidding/list/biddings-transmission-dialog.tsx | 159 +++++++++++++++++++++ 2 files changed, 224 insertions(+), 35 deletions(-) create mode 100644 lib/bidding/list/biddings-transmission-dialog.tsx (limited to 'lib/bidding/list') 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 @@ -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 ( -
- {/* 신규 생성 */} - + <> +
+ {/* 신규 생성 */} + - {/* 개찰 (입찰 오픈) */} - {/* {openEligibleBiddings.length > 0 && ( - - )} */} - {/* Export */} - - + {/* 개찰 (입찰 오픈) */} + {/* {openEligibleBiddings.length > 0 && ( - - - - - 입찰 목록 내보내기 - - - -
+ )} */} + + {/* Export */} + + + + + + + + 입찰 목록 내보내기 + + + +
+ + {/* 전송 다이얼로그 */} + + ) } \ No newline at end of file diff --git a/lib/bidding/list/biddings-transmission-dialog.tsx b/lib/bidding/list/biddings-transmission-dialog.tsx new file mode 100644 index 00000000..d307ec9d --- /dev/null +++ b/lib/bidding/list/biddings-transmission-dialog.tsx @@ -0,0 +1,159 @@ +"use client" + +import * as React from "react" +import { + Send, CheckCircle, FileText, Truck +} from "lucide-react" +import { toast } from "sonner" +import { Button } from "@/components/ui/button" +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog" +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" +import { Label } from "@/components/ui/label" +import { BiddingListItem } from "@/db/schema" +import { transmitToContract, transmitToPO } from "@/lib/bidding/actions" + +console.log('=== Module loaded ===') +console.log('transmitToContract imported:', typeof transmitToContract) +console.log('transmitToPO imported:', typeof transmitToPO) + +interface TransmissionDialogProps { + open: boolean + onOpenChange: (open: boolean) => void + bidding: BiddingListItem | undefined + userId: number +} + +export function TransmissionDialog({ open, onOpenChange, bidding, userId }: TransmissionDialogProps) { + const [isLoading, setIsLoading] = React.useState(false) + + if (!bidding) return null + + const handleToContract = async () => { + try { + setIsLoading(true) + console.log('=== START handleToContract ===') + console.log('bidding.id', bidding.id) + console.log('userId', userId) + console.log('transmitToContract function:', typeof transmitToContract) + + console.log('About to call transmitToContract...') + const result = await transmitToContract(bidding.id, userId) + console.log('transmitToContract result:', result) + + toast.success('계약서 생성이 완료되었습니다.') + onOpenChange(false) + } catch (error) { + console.error('handleToContract error:', error) + toast.error(`계약서 생성에 실패했습니다: ${error}`) + } finally { + setIsLoading(false) + console.log('=== END handleToContract ===') + } + } + + const handleToPO = async () => { + try { + setIsLoading(true) + await transmitToPO(bidding.id) + toast.success('PO 전송이 완료되었습니다.') + onOpenChange(false) + } catch (error) { + toast.error(`PO 전송에 실패했습니다: ${error}`) + } finally { + setIsLoading(false) + } + } + + return ( + + + + + + 입찰 전송 + + + 선택된 입찰을 계약서 또는 PO로 전송합니다. + + + +
+ {/* 입찰 정보 */} + + + 입찰 정보 + + +
+
+ +

{bidding.biddingNumber}

+
+
+ +

{bidding.title}

+
+
+ +

{bidding.contractType}

+
+
+ +

+ {bidding.budget ? `${bidding.budget.toLocaleString()} ${bidding.currency}` : '-'} +

+
+
+
+
+ + {/* 선정된 업체 정보 (임시로 표시) */} + + + 선정된 업체 + + +
+ + 업체 선정이 완료되었습니다. +
+

+ 자세한 업체 정보는 전송 후 확인할 수 있습니다. +

+
+
+
+ + + + + + +
+
+ ) +} -- cgit v1.2.3