From 8642ee064ddf96f1db2b948b4cc8bbbd6cfee820 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Wed, 12 Nov 2025 10:42:36 +0000 Subject: (최겸) 구매 일반계약, 입찰 수정 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bidding/selection/selection-result-form.tsx | 143 ++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 lib/bidding/selection/selection-result-form.tsx (limited to 'lib/bidding/selection/selection-result-form.tsx') diff --git a/lib/bidding/selection/selection-result-form.tsx b/lib/bidding/selection/selection-result-form.tsx new file mode 100644 index 00000000..7f1229a2 --- /dev/null +++ b/lib/bidding/selection/selection-result-form.tsx @@ -0,0 +1,143 @@ +'use client' + +import * as React from 'react' +import { useForm } from 'react-hook-form' +import { zodResolver } from '@hookform/resolvers/zod' +import * as z from 'zod' +import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' +import { Button } from '@/components/ui/button' +import { Textarea } from '@/components/ui/textarea' +import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form' +import { FileUpload } from '@/components/ui/file-upload' +import { useToast } from '@/hooks/use-toast' +import { saveSelectionResult } from './actions' +import { Loader2, Save } from 'lucide-react' + +const selectionResultSchema = z.object({ + summary: z.string().min(1, '결과요약을 입력해주세요'), + attachments: z.array(z.any()).optional(), +}) + +type SelectionResultFormData = z.infer + +interface SelectionResultFormProps { + biddingId: number + onSuccess: () => void +} + +export function SelectionResultForm({ biddingId, onSuccess }: SelectionResultFormProps) { + const { toast } = useToast() + const [isSubmitting, setIsSubmitting] = React.useState(false) + + const form = useForm({ + resolver: zodResolver(selectionResultSchema), + defaultValues: { + summary: '', + attachments: [], + }, + }) + + const onSubmit = async (data: SelectionResultFormData) => { + setIsSubmitting(true) + try { + const result = await saveSelectionResult({ + biddingId, + summary: data.summary, + attachments: data.attachments + }) + + if (result.success) { + toast({ + title: '저장 완료', + description: result.message, + }) + onSuccess() + } else { + toast({ + title: '저장 실패', + description: result.error, + variant: 'destructive', + }) + } + } catch (error) { + console.error('Failed to save selection result:', error) + toast({ + title: '저장 실패', + description: '선정결과 저장 중 오류가 발생했습니다.', + variant: 'destructive', + }) + } finally { + setIsSubmitting(false) + } + } + + return ( + + + 선정결과 + + +
+ + {/* 결과요약 */} + ( + + 결과요약 + +