// 폐찰하기 다이얼로그 "use client" import { useState } from "react" import { useSession } from "next-auth/react" import { toast } from "sonner" import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog" import { Label } from "@/components/ui/label" import { Textarea } from "@/components/ui/textarea" import { Input } from "@/components/ui/input" import { Button } from "@/components/ui/button" import { FileXIcon } from "lucide-react" interface BiddingsClosureDialogProps { open: boolean; onOpenChange: (open: boolean) => void; bidding: { id: number; title: string; biddingNumber: string; } | null; onSuccess?: () => void; onApprovalPreview: (data: { description: string; files: File[]; biddingId: number }) => Promise; } export function BiddingsClosureDialog({ open, onOpenChange, bidding, onSuccess, onApprovalPreview }: BiddingsClosureDialogProps) { const { data: session } = useSession() const [description, setDescription] = useState('') const [files, setFiles] = useState([]) const handleNextStep = async (e: React.FormEvent) => { e.preventDefault() if (!bidding || !description.trim()) { toast.error('폐찰 사유를 입력해주세요.') return } try { // 결재자 선택 단계로 데이터 전달 await onApprovalPreview({ description: description.trim(), files: files, biddingId: bidding.id, }) // 다이얼로그 닫기 onOpenChange(false) } catch (error) { console.error('결재 미리보기 준비 실패:', error) toast.error('결재 미리보기 준비 중 오류가 발생했습니다.') } } const handleFileChange = (e: React.ChangeEvent) => { if (e.target.files) { setFiles(Array.from(e.target.files)) } } if (!bidding) return null return ( 폐찰하기 {bidding.title} ({bidding.biddingNumber})를 폐찰합니다.