From ba8cd44a0ed2c613a5f2cee06bfc9bd0f61f21c7 Mon Sep 17 00:00:00 2001 From: dujinkim 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 --- components/bidding/bidding-round-actions.tsx | 201 +++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 components/bidding/bidding-round-actions.tsx (limited to 'components/bidding/bidding-round-actions.tsx') diff --git a/components/bidding/bidding-round-actions.tsx b/components/bidding/bidding-round-actions.tsx new file mode 100644 index 00000000..b2db0dfb --- /dev/null +++ b/components/bidding/bidding-round-actions.tsx @@ -0,0 +1,201 @@ +"use client" + +import * as React from "react" +import { useRouter } from "next/navigation" +import { useTransition } from "react" +import { Button } from "@/components/ui/button" +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" +import { RefreshCw, RotateCw } from "lucide-react" +import { increaseRoundOrRebid } from "@/lib/bidding/service" +import { useToast } from "@/hooks/use-toast" + +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, +} from "@/components/ui/alert-dialog" +import { useSession } from "next-auth/react" + +interface BiddingRoundActionsProps { + biddingId: number + biddingStatus?: string +} + +export function BiddingRoundActions({ biddingId, biddingStatus }: BiddingRoundActionsProps) { + const router = useRouter() + const { toast } = useToast() + const [isPending, startTransition] = useTransition() + const [showRoundDialog, setShowRoundDialog] = React.useState(false) + const [showRebidDialog, setShowRebidDialog] = React.useState(false) + const { data: session } = useSession() + const userId = session?.user?.id + + // 차수증가는 유찰 상태에서만 가능 + const canIncreaseRound = biddingStatus === 'bidding_disposal' + + // 재입찰도 유찰 상태에서만 가능 + const canRebid = biddingStatus === 'bidding_disposal' + + const handleRoundIncrease = () => { + startTransition(async () => { + try { + const result = await increaseRoundOrRebid(biddingId, userId, 'round_increase') + + if (result.success) { + toast({ + title: "성공", + description: result.message, + variant: "default", + }) + setShowRoundDialog(false) + // 새로 생성된 입찰 페이지로 이동 + if (result.biddingId) { + router.push(`/evcp/bid/${result.biddingId}`) + router.refresh() + } + } else { + toast({ + title: "오류", + description: result.error || "차수증가 중 오류가 발생했습니다.", + variant: "destructive", + }) + } + } catch (error) { + console.error('차수증가 실패:', error) + toast({ + title: "오류", + description: "차수증가 중 오류가 발생했습니다.", + variant: "destructive", + }) + } + }) + } + + const handleRebid = () => { + startTransition(async () => { + try { + const result = await increaseRoundOrRebid(biddingId, userId, 'rebidding') + + if (result.success) { + toast({ + title: "성공", + description: result.message, + variant: "default", + }) + setShowRebidDialog(false) + // 새로 생성된 입찰 페이지로 이동 + if (result.biddingId) { + router.push(`/evcp/bid/${result.biddingId}`) + router.refresh() + } + } else { + toast({ + title: "오류", + description: result.error || "재입찰 중 오류가 발생했습니다.", + variant: "destructive", + }) + } + } catch (error) { + console.error('재입찰 실패:', error) + toast({ + title: "오류", + description: "재입찰 중 오류가 발생했습니다.", + variant: "destructive", + }) + } + }) + } + + // 유찰 상태가 아니면 컴포넌트를 렌더링하지 않음 + if (!canIncreaseRound && !canRebid) { + return null + } + + return ( + <> + + + 입찰 차수 관리 + + +
+ + +
+

+ 유찰 상태에서 차수증가 또는 재입찰을 진행할 수 있습니다. +

+
+
+ + {/* 차수증가 확인 다이얼로그 */} + + + + 차수증가 + + 현재 입찰의 정보를 복제하여 새로운 차수의 입찰을 생성합니다. +
+ 기존 입찰 조건, 아이템, 벤더 정보가 복제되며, 벤더 제출 정보는 초기화됩니다. +
+
+ 계속하시겠습니까? +
+
+ + 취소 + + {isPending ? "처리중..." : "확인"} + + +
+
+ + {/* 재입찰 확인 다이얼로그 */} + + + + 재입찰 + + 현재 입찰의 정보를 복제하여 재입찰을 생성합니다. +
+ 기존 입찰 조건, 아이템, 벤더 정보가 복제되며, 벤더 제출 정보는 초기화됩니다. +
+
+ 계속하시겠습니까? +
+
+ + 취소 + + {isPending ? "처리중..." : "확인"} + + +
+
+ + ) +} + + -- cgit v1.2.3