summaryrefslogtreecommitdiff
path: root/components/bidding/manage/create-pre-quote-rfq-dialog.tsx
blob: 1ab7a40f3dfea4733c4065f95d697274d727e9ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
"use client"

import * as React from "react"
import { useForm, useFieldArray } from "react-hook-form"
import { zodResolver } from "@hookform/resolvers/zod"
import { z } from "zod"
import { format } from "date-fns"
import { CalendarIcon, Loader2, Trash2, PlusCircle } from "lucide-react"
import { useSession } from "next-auth/react"

import { Button } from "@/components/ui/button"
import {
  Dialog,
  DialogContent,
  DialogDescription,
  DialogFooter,
  DialogHeader,
  DialogTitle,
} from "@/components/ui/dialog"
import {
  Form,
  FormControl,
  FormField,
  FormItem,
  FormLabel,
  FormMessage,
  FormDescription,
} from "@/components/ui/form"
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from "@/components/ui/select"
import { Input } from "@/components/ui/input"
import { Textarea } from "@/components/ui/textarea"
import {
  Popover,
  PopoverContent,
  PopoverTrigger,
} from "@/components/ui/popover"
import { Calendar } from "@/components/ui/calendar"
import { Badge } from "@/components/ui/badge"
import { cn } from "@/lib/utils"
import { toast } from "sonner"
import { ScrollArea } from "@/components/ui/scroll-area"
import { Separator } from "@/components/ui/separator"
import { createPreQuoteRfqAction } from "@/lib/bidding/pre-quote/service"
import { previewGeneralRfqCode } from "@/lib/rfq-last/service"
import { MaterialGroupSelectorDialogSingle } from "@/components/common/material/material-group-selector-dialog-single"
import { MaterialSearchItem } from "@/lib/material/material-group-service"
import { MaterialSelectorDialogSingle } from "@/components/common/selectors/material/material-selector-dialog-single"
import { MaterialSearchItem as SAPMaterialSearchItem } from "@/components/common/selectors/material/material-service"
import { PurchaseGroupCodeSelector } from "@/components/common/selectors/purchase-group-code/purchase-group-code-selector"
import type { PurchaseGroupCodeWithUser } from "@/components/common/selectors/purchase-group-code"
import { getBiddingById } from "@/lib/bidding/service"

// 아이템 스키마
const itemSchema = z.object({
  itemCode: z.string().optional(),
  itemName: z.string().optional(),
  materialCode: z.string().optional(),
  materialName: z.string().optional(),
  quantity: z.number().min(1, "수량은 1 이상이어야 합니다"),
  uom: z.string().min(1, "단위를 입력해주세요"),
  remark: z.string().optional(),
})

// 사전견적용 일반견적 생성 폼 스키마
const createPreQuoteRfqSchema = z.object({
  rfqType: z.string().optional(),
  rfqTitle: z.string().min(1, "견적명을 입력해주세요"),
  dueDate: z.date({
    required_error: "제출마감일을 선택해주세요",
  }).optional(), // 필수값 해제
  picUserId: z.number().optional(),
  projectId: z.number().optional(),
  remark: z.string().optional(),
  biddingNumber: z.string().optional(), // 입찰 No. 추가
  contractStartDate: z.date().optional(), // 계약기간 시작
  contractEndDate: z.date().optional(), // 계약기간 종료
  items: z.array(itemSchema).min(1, "최소 하나의 자재를 추가해주세요"),
})

type CreatePreQuoteRfqFormValues = z.infer<typeof createPreQuoteRfqSchema>

interface CreatePreQuoteRfqDialogProps {
  open: boolean
  onOpenChange: (open: boolean) => void
  biddingId: number
  biddingItems: Array<{
    id: number
    materialGroupNumber?: string | null
    materialGroupInfo?: string | null
    materialNumber?: string | null
    materialInfo?: string | null
    quantity?: string | null
    quantityUnit?: string | null
    totalWeight?: string | null
    weightUnit?: string | null
  }>
  picUserId?: number | null
  biddingConditions?: {
    paymentTerms?: string | null
    taxConditions?: string | null
    incoterms?: string | null
    incotermsOption?: string | null
    contractDeliveryDate?: string | null
    shippingPort?: string | null
    destinationPort?: string | null
    isPriceAdjustmentApplicable?: boolean | null
    sparePartOptions?: string | null
  } | null
  onSuccess?: () => void
}

export function CreatePreQuoteRfqDialog({
  open,
  onOpenChange,
  biddingId,
  biddingItems,
  picUserId,
  biddingConditions,
  onSuccess
}: CreatePreQuoteRfqDialogProps) {
  const [isLoading, setIsLoading] = React.useState(false)
  const [previewCode, setPreviewCode] = React.useState("")
  const [isLoadingPreview, setIsLoadingPreview] = React.useState(false)
  const [selectedBidPic, setSelectedBidPic] = React.useState<PurchaseGroupCodeWithUser | undefined>(undefined)
  const { data: session } = useSession()

  const userId = React.useMemo(() => {
    return session?.user?.id ? Number(session.user.id) : null;
  }, [session]);

  // 입찰품목을 일반견적 아이템으로 매핑
  const initialItems = React.useMemo(() => {
    return biddingItems.map((item) => ({
      itemCode: item.materialGroupNumber || "",
      itemName: item.materialGroupInfo || "",
      materialCode: item.materialNumber || "",
      materialName: item.materialInfo || "",
      quantity: item.quantity ? parseFloat(item.quantity) : 1,
      uom: item.quantityUnit || item.weightUnit || "EA",
      remark: "",
    }))
  }, [biddingItems])

  const form = useForm<CreatePreQuoteRfqFormValues>({
    resolver: zodResolver(createPreQuoteRfqSchema),
    defaultValues: {
      rfqType: "",
      rfqTitle: "",
      dueDate: undefined,
      picUserId: undefined,
      projectId: undefined,
      remark: "",
      items: initialItems.length > 0 ? initialItems : [
        {
          itemCode: "",
          itemName: "",
          materialCode: "",
          materialName: "",
          quantity: 1,
          uom: "",
          remark: "",
        },
      ],
    },
  })

  /*
  const { fields, append, remove } = useFieldArray({
    control: form.control,
    name: "items",
  })
  */

  // 견적담당자 정보 로드
  React.useEffect(() => {
    const loadBiddingInfo = async () => {
      if (!biddingId || !open) return

      try {
        const bidding = await getBiddingById(biddingId)
        if (bidding) {
          setSelectedBidPic({
            DISPLAY_NAME: bidding.bidPicName || '',
            PURCHASE_GROUP_CODE: bidding.bidPicCode || '',
            EMPLOYEE_NUMBER: '',
            user: bidding.bidPicId ? {
              id: bidding.bidPicId,
              name: bidding.bidPicName || '',
              email: '',
              employeeNumber: null
            } : undefined
          })
        }
      } catch (error) {
        console.error('Failed to load bidding info:', error)
      }
    }

    loadBiddingInfo()
  }, [biddingId, open])
  
  // 프로젝트 정보 상태 추가
  const [projectInfo, setProjectInfo] = React.useState<string>("")

  // 다이얼로그가 열릴 때 폼 초기화
  React.useEffect(() => {
    if (open) {
      // 입찰 정보를 기반으로 기본값 설정
      let rfqTitle = "";
      let projectId: number | undefined = undefined;
      let contractStartDate: Date | undefined = undefined;
      let contractEndDate: Date | undefined = undefined;
      let biddingNumber = "";

      const loadDetailedBiddingInfo = async () => {
        if (biddingId) {
          try {
            const bidding = await getBiddingById(biddingId)
            if (bidding) {
              rfqTitle = bidding.title;
              biddingNumber = bidding.biddingNumber;
              
              // 프로젝트 정보 설정
              const pCode = bidding.projectCode || "";
              const pName = bidding.projectName || "";
              setProjectInfo(pCode && pName ? `${pCode} - ${pName}` : pCode || pName || "");

              // 폼 값 설정
              form.setValue("rfqTitle", rfqTitle);
              form.setValue("rfqType", "pre_bidding"); // 기본값 설정
              if (biddingNumber) form.setValue("biddingNumber", biddingNumber);
              
              if (bidding.contractStartDate) form.setValue("contractStartDate", new Date(bidding.contractStartDate));
              if (bidding.contractEndDate) form.setValue("contractEndDate", new Date(bidding.contractEndDate));
            }
          } catch (e) {
            console.error(e);
          }
        }
      };
      loadDetailedBiddingInfo();

      form.reset({
        rfqType: "pre_bidding", // 기본값
        rfqTitle: "",
        dueDate: undefined, // 필수값 해제되었으므로 undefined 가능
        picUserId: selectedBidPic?.user?.id,
        projectId: undefined,
        remark: "",
        biddingNumber: "",
        contractStartDate: undefined,
        contractEndDate: undefined,
        items: initialItems.length > 0 ? initialItems : [
          {
            itemCode: "",
            itemName: "",
            materialCode: "",
            materialName: "",
            quantity: 1,
            uom: "",
            remark: "",
          },
        ],
      })
      setPreviewCode("")
    }
  }, [open, initialItems, form, selectedBidPic, biddingId])

  // 견적담당자 선택 시 RFQ 코드 미리보기 생성
  React.useEffect(() => {
    if (!selectedBidPic?.user?.id) {
      setPreviewCode("")
      return
    }

    // 즉시 실행 함수 패턴 사용
    (async () => {
      setIsLoadingPreview(true)
      try {
        const code = await previewGeneralRfqCode(selectedBidPic.user!.id)
        setPreviewCode(code)
      } catch (error) {
        console.error("코드 미리보기 오류:", error)
        setPreviewCode("")
      } finally {
        setIsLoadingPreview(false)
      }
    })()
  }, [selectedBidPic])

  // 견적 종류 변경
  const handleRfqTypeChange = (value: string) => {
    form.setValue("rfqType", value)
  }

  const handleCancel = () => {
    form.reset({
      rfqType: "",
      rfqTitle: "",
      dueDate: undefined,
      picUserId: undefined,
      projectId: undefined,
      remark: "",
      items: initialItems.length > 0 ? initialItems : [
        {
          itemCode: "",
          itemName: "",
          materialCode: "",
          materialName: "",
          quantity: 1,
          uom: "",
          remark: "",
        },
      ],
    })
      setSelectedBidPic(undefined)
      setPreviewCode("")
    onOpenChange(false)
  }

  const onSubmit = async (data: CreatePreQuoteRfqFormValues) => {
    if (!userId) {
      toast.error("로그인이 필요합니다")
      return
    }



    const picUserId = selectedBidPic?.user?.id || session?.user?.id

    setIsLoading(true)
    
    try {
      // 서버 액션 호출 (입찰 조건 포함)
      const result = await createPreQuoteRfqAction({
        // biddingId, // createPreQuoteRfqAction 인터페이스 변경됨
        biddingId,
        rfqType: data.rfqType || "pre_bidding",
        rfqTitle: data.rfqTitle,
        dueDate: data.dueDate ? new Date(data.dueDate) : undefined, // optional이지만 submit시에는 값이 있을 수 있음 (없으면 서비스에서 처리)
        picUserId,
        projectId: data.projectId,
        remark: data.remark || "",
        biddingNumber: data.biddingNumber, // 추가
        contractStartDate: data.contractStartDate, // 추가
        contractEndDate: data.contractEndDate, // 추가
        items: data.items as Array<{
          itemCode: string;
          itemName: string;
          materialCode?: string;
          materialName?: string;
          quantity: number;
          uom: string;
          remark?: string;
        }>,
        biddingConditions: biddingConditions || undefined,
        createdBy: userId,
        updatedBy: userId,
      })

      if (result.success) {
        toast.success(result.message, {
          description: result.data?.rfqCode ? `RFQ 코드: ${result.data.rfqCode}` : undefined,
        })

        // 다이얼로그 닫기
        onOpenChange(false)
        
        // 성공 콜백 실행
        if (onSuccess) {
          onSuccess()
        }
      } else {
        toast.error(result.error || "사전견적용 일반견적 생성에 실패했습니다")
      }
      
    } catch (error) {
      console.error('사전견적용 일반견적 생성 오류:', error)
      toast.error("사전견적용 일반견적 생성에 실패했습니다", {
        description: "알 수 없는 오류가 발생했습니다",
      })
    } finally {
      setIsLoading(false)
    }
  }

  // 아이템 추가 (사용안함)
  /*
  const handleAddItem = () => {
    append({
      itemCode: "",
      itemName: "",
      materialCode: "",
      materialName: "",
      quantity: 1,
      uom: "",
      remark: "",
    })
  }
  */

  return (
    <Dialog open={open} onOpenChange={onOpenChange}>
      <DialogContent className="max-w-4xl h-[90vh] flex flex-col">
        {/* 고정된 헤더 */}
        <DialogHeader className="flex-shrink-0">
          <DialogTitle>사전견적용 일반견적 생성</DialogTitle>
          <DialogDescription>
            입찰의 사전견적을 위한 일반견적을 생성합니다. 입찰품목이 자재정보로 매핑되어 있습니다.
          </DialogDescription>
        </DialogHeader>

        {/* 스크롤 가능한 컨텐츠 영역 */}
        <ScrollArea className="flex-1 px-1">
          <Form {...form}>
            <form id="createPreQuoteRfqForm" onSubmit={form.handleSubmit(onSubmit)} className="space-y-6 py-2">
              
              {/* 기본 정보 섹션 */}
              <div className="space-y-4">
                <h3 className="text-lg font-semibold">기본 정보</h3>
                
                <div className="grid grid-cols-2 gap-4">
                  {/* 견적 종류 */}
                  {/* <div className="space-y-2">
                    <FormField
                      control={form.control}
                      name="rfqType"
                      render={({ field }) => (
                        <FormItem className="flex flex-col">
                          <FormLabel>
                            견적 종류 <span className="text-red-500">*</span>
                          </FormLabel>
                          <FormControl>
                            <Input {...field} value="사전견적(입찰)" readOnly className="bg-muted" />
                          </FormControl>
                          <FormMessage />
                        </FormItem>
                      )}
                    />
                  </div> */}

                  {/* 제출마감일 */}
                  <FormField
                    control={form.control}
                    name="dueDate"
                    render={({ field }) => (
                      <FormItem className="flex flex-col">
                        <FormLabel>
                          제출마감일
                        </FormLabel>
                        <Popover>
                          <PopoverTrigger asChild>
                            <FormControl>
                              <Button
                                variant="outline"
                                className={cn(
                                  "w-full pl-3 text-left font-normal",
                                  !field.value && "text-muted-foreground"
                                )}
                              >
                                {field.value ? (
                                  format(field.value, "yyyy-MM-dd HH:mm")
                                ) : (
                                  <span>제출마감일을 선택하세요 (선택)</span>
                                )}
                                <CalendarIcon className="ml-auto h-4 w-4 opacity-50" />
                              </Button>
                            </FormControl>
                          </PopoverTrigger>
                          <PopoverContent className="w-auto p-0" align="start">
                            <Calendar
                              mode="single"
                              selected={field.value}
                              onSelect={(date) => {
                                if (!date) {
                                  field.onChange(undefined)
                                  return
                                }
                                const newDate = new Date(date)
                                if (field.value) {
                                  newDate.setHours(field.value.getHours(), field.value.getMinutes())
                                } else {
                                  newDate.setHours(0, 0, 0, 0)
                                }
                                field.onChange(newDate)
                              }}
                              disabled={(date) => {
                                const today = new Date()
                                today.setHours(0, 0, 0, 0)
                                return date < today || date < new Date("1900-01-01")
                              }}
                              initialFocus
                            />
                            <div className="p-3 border-t border-border">
                              <Input
                                type="time"
                                value={field.value ? format(field.value, "HH:mm") : ""}
                                onChange={(e) => {
                                  if (field.value) {
                                    const [hours, minutes] = e.target.value.split(':').map(Number)
                                    const newDate = new Date(field.value)
                                    newDate.setHours(hours, minutes)
                                    field.onChange(newDate)
                                  }
                                }}
                              />
                            </div>
                          </PopoverContent>
                        </Popover>
                        <FormMessage />
                      </FormItem>
                    )}
                  />
                </div>

                {/* 견적명 */}
                <FormField
                  control={form.control}
                  name="rfqTitle"
                  render={({ field }) => (
                    <FormItem>
                      <FormLabel>
                        견적명 <span className="text-red-500">*</span>
                      </FormLabel>
                      <FormControl>
                        <Input
                          placeholder="예: 입찰 사전견적용 일반견적"
                          {...field}
                        />
                      </FormControl>
                      <FormDescription>
                        견적의 목적이나 내용을 간단명료하게 입력해주세요
                      </FormDescription>
                      <FormMessage />
                    </FormItem>
                  )}
                />

                {/* 프로젝트 선택 */}
                <div className="space-y-2">
                    <FormItem className="flex flex-col">
                      <FormLabel>프로젝트</FormLabel>
                      <FormControl>
                        <Input
                          value={projectInfo}
                          readOnly
                          className="bg-muted"
                          placeholder="프로젝트 정보 없음"
                        />
                      </FormControl>
                    </FormItem>
                </div>
                <FormField
                  control={form.control}
                  name="projectId"
                  render={({ field }) => (
                    <input type="hidden" {...field} value={field.value || ''} />
                  )}
                />

                {/* 담당자 정보 */}
                <FormField
                  control={form.control}
                  name="picUserId"
                  render={({ field }) => (
                    <FormItem className="flex flex-col">
                      <FormLabel>
                        견적담당자 <span className="text-red-500">*</span>
                      </FormLabel>
                      <FormControl>
                        <PurchaseGroupCodeSelector
                          selectedCode={selectedBidPic}
                          onCodeSelect={(code) => {
                            setSelectedBidPic(code)
                            field.onChange(code.user?.id)
                          }}
                          placeholder="입찰담당자 선택"
                        />
                      </FormControl>
                      <FormDescription>
                        사전견적용 일반견적의 담당자를 선택합니다
                      </FormDescription>
                      <FormMessage />
                    </FormItem>
                  )}
                />
                {/* RFQ 코드 미리보기 */}
                {previewCode && (
                  <div className="flex items-center gap-2">
                    <Badge variant="secondary" className="font-mono text-sm">
                      예상 RFQ 코드: {previewCode}
                    </Badge>
                    {isLoadingPreview && (
                      <Loader2 className="h-3 w-3 animate-spin" />
                    )}
                  </div>
                )}

                {/* 계약기간 */}
                <div className="grid grid-cols-2 gap-4">
                  <FormField
                    control={form.control}
                    name="contractStartDate"
                    render={({ field }) => (
                      <FormItem className="flex flex-col">
                        <FormLabel>계약기간 시작</FormLabel>
                        <Popover>
                          <PopoverTrigger asChild>
                            <FormControl>
                              <Button
                                variant="outline"
                                className={cn(
                                  "w-full pl-3 text-left font-normal",
                                  !field.value && "text-muted-foreground"
                                )}
                              >
                                {field.value ? (
                                  format(field.value, "yyyy-MM-dd")
                                ) : (
                                  <span>시작일 선택</span>
                                )}
                                <CalendarIcon className="ml-auto h-4 w-4 opacity-50" />
                              </Button>
                            </FormControl>
                          </PopoverTrigger>
                          <PopoverContent className="w-auto p-0" align="start">
                            <Calendar
                              mode="single"
                              selected={field.value}
                              onSelect={field.onChange}
                              initialFocus
                            />
                          </PopoverContent>
                        </Popover>
                        <FormMessage />
                      </FormItem>
                    )}
                  />

                  <FormField
                    control={form.control}
                    name="contractEndDate"
                    render={({ field }) => (
                      <FormItem className="flex flex-col">
                        <FormLabel>계약기간 종료</FormLabel>
                        <Popover>
                          <PopoverTrigger asChild>
                            <FormControl>
                              <Button
                                variant="outline"
                                className={cn(
                                  "w-full pl-3 text-left font-normal",
                                  !field.value && "text-muted-foreground"
                                )}
                              >
                                {field.value ? (
                                  format(field.value, "yyyy-MM-dd")
                                ) : (
                                  <span>종료일 선택</span>
                                )}
                                <CalendarIcon className="ml-auto h-4 w-4 opacity-50" />
                              </Button>
                            </FormControl>
                          </PopoverTrigger>
                          <PopoverContent className="w-auto p-0" align="start">
                            <Calendar
                              mode="single"
                              selected={field.value}
                              onSelect={field.onChange}
                              initialFocus
                            />
                          </PopoverContent>
                        </Popover>
                        <FormMessage />
                      </FormItem>
                    )}
                  />
                </div>

                {/* 비고 */}
                <FormField
                  control={form.control}
                  name="remark"
                  render={({ field }) => (
                    <FormItem>
                      <FormLabel>비고</FormLabel>
                      <FormControl>
                        <Textarea
                          placeholder="추가 비고사항을 입력하세요"
                          className="resize-none"
                          rows={3}
                          {...field}
                        />
                      </FormControl>
                      <FormMessage />
                    </FormItem>
                  )}
                />
              </div>

              <Separator />

              {/* 아이템 정보 섹션 (자동 매핑되므로 UI 제거) */}
              {/* <div className="space-y-4">
                ...
              </div> */}
            </form>
          </Form>
        </ScrollArea>

        {/* 고정된 푸터 */}
        <DialogFooter className="flex-shrink-0">
          <Button
            type="button"
            variant="outline"
            onClick={handleCancel}
            disabled={isLoading}
          >
            취소
          </Button>
          <Button
            type="submit"
            form="createPreQuoteRfqForm"
            onClick={form.handleSubmit(onSubmit)}
            disabled={isLoading}
          >
            {isLoading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
            {isLoading ? "생성 중..." : "사전견적용 일반견적 생성"}
          </Button>
        </DialogFooter>
      </DialogContent>
    </Dialog>
  )
}