From b75b1cd920efd61923f7b2dbc4c49987b7b0c4e1 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Thu, 20 Nov 2025 10:25:41 +0000
Subject: (최겸) 구매 입찰 수정
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../bidding/create/bidding-create-dialog.tsx       | 118 ++++++++++-----------
 1 file changed, 56 insertions(+), 62 deletions(-)

(limited to 'components/bidding/create/bidding-create-dialog.tsx')

diff --git a/components/bidding/create/bidding-create-dialog.tsx b/components/bidding/create/bidding-create-dialog.tsx
index ad9555db..9b0a6f66 100644
--- a/components/bidding/create/bidding-create-dialog.tsx
+++ b/components/bidding/create/bidding-create-dialog.tsx
@@ -45,6 +45,7 @@ import {
   DropzoneDescription,
   DropzoneInput,
   DropzoneTitle,
+  DropzoneTrigger,
   DropzoneUploadIcon,
   DropzoneZone,
 } from "@/components/ui/dropzone"
@@ -198,28 +199,28 @@ export function BiddingCreateDialog({ form, onSuccess }: BiddingCreateDialogProp
 
   React.useEffect(() => {
     const loadNoticeTemplate = async () => {
-      if (selectedNoticeType) {
-        setIsLoadingTemplate(true)
-        try {
-          const template = await getBiddingNoticeTemplate(selectedNoticeType)
-          if (template) {
-            setNoticeTemplate(template.content)
-            // 폼의 content 필드도 업데이트
-            form.setValue('content', template.content)
-          } else {
-            // 템플릿이 없으면 표준 템플릿 사용
-            const defaultTemplate = await getBiddingNoticeTemplate('standard')
-            if (defaultTemplate) {
-              setNoticeTemplate(defaultTemplate.content)
-              form.setValue('content', defaultTemplate.content)
-            }
+      setIsLoadingTemplate(true)
+      try {
+        // 처음 로드할 때는 무조건 standard 템플릿 사용
+        const templateType = selectedNoticeType || 'standard'
+        const template = await getBiddingNoticeTemplate(templateType)
+        if (template) {
+          setNoticeTemplate(template.content)
+          // 폼의 content 필드도 업데이트
+          form.setValue('content', template.content)
+        } else {
+          // 템플릿이 없으면 표준 템플릿 사용
+          const defaultTemplate = await getBiddingNoticeTemplate('standard')
+          if (defaultTemplate) {
+            setNoticeTemplate(defaultTemplate.content)
+            form.setValue('content', defaultTemplate.content)
           }
-        } catch (error) {
-          console.error('Failed to load notice template:', error)
-          toast.error('입찰공고 템플릿을 불러오는데 실패했습니다.')
-        } finally {
-          setIsLoadingTemplate(false)
         }
+      } catch (error) {
+        console.error('Failed to load notice template:', error)
+        toast.error('입찰공고 템플릿을 불러오는데 실패했습니다.')
+      } finally {
+        setIsLoadingTemplate(false)
       }
     }
 
@@ -279,30 +280,13 @@ export function BiddingCreateDialog({ form, onSuccess }: BiddingCreateDialogProp
         return
       }
 
-      // 첨부파일 정보 설정 (실제로는 파일 업로드 후 저장해야 함)
-      const attachments = shiAttachmentFiles.map((file, index) => ({
-        id: `shi_${Date.now()}_${index}`,
-        fileName: file.name,
-        fileSize: file.size,
-        filePath: '', // 실제 업로드 후 경로
-        uploadedAt: new Date().toISOString(),
-        type: 'shi' as const,
-      }))
-
-      const vendorAttachments = vendorAttachmentFiles.map((file, index) => ({
-        id: `vendor_${Date.now()}_${index}`,
-        fileName: file.name,
-        fileSize: file.size,
-        filePath: '', // 실제 업로드 후 경로
-        uploadedAt: new Date().toISOString(),
-        type: 'vendor' as const,
-      }))
+      // 첨부파일 정보 설정
 
       // sparePartOptions가 undefined인 경우 빈 문자열로 설정
       const biddingData = {
         ...data,
-        attachments,
-        vendorAttachments,
+        attachments: shiAttachmentFiles, // 실제 파일 객체들 전달
+        vendorAttachments: vendorAttachmentFiles, // 실제 파일 객체들 전달
         biddingConditions: {
           ...data.biddingConditions,
           sparePartOptions: data.biddingConditions.sparePartOptions || '',
@@ -396,7 +380,7 @@ export function BiddingCreateDialog({ form, onSuccess }: BiddingCreateDialogProp
                   </CardTitle>
                 </CardHeader>
                 <CardContent className="space-y-4">
-                  {/* 1행: 입찰명, 낙찰수, 입찰유형, 계약구분 */}
+                  {/* 1행: 입찰명, 낙찰업체 수, 입찰유형, 계약구분 */}
                   <div className="grid grid-cols-4 gap-4">
                     <FormField
                       control={form.control}
@@ -417,11 +401,11 @@ export function BiddingCreateDialog({ form, onSuccess }: BiddingCreateDialogProp
                       name="awardCount"
                       render={({ field }) => (
                         <FormItem>
-                          <FormLabel>낙찰수 <span className="text-red-500">*</span></FormLabel>
+                          <FormLabel>낙찰업체 수<span className="text-red-500">*</span></FormLabel>
                           <Select onValueChange={field.onChange} defaultValue={field.value}>
                             <FormControl>
                               <SelectTrigger>
-                                <SelectValue placeholder="낙찰수 선택" />
+                                <SelectValue placeholder="낙찰업체 수 선택" />
                               </SelectTrigger>
                             </FormControl>
                             <SelectContent>
@@ -982,9 +966,15 @@ export function BiddingCreateDialog({ form, onSuccess }: BiddingCreateDialogProp
                               </SelectTrigger>
                             </FormControl>
                             <SelectContent>
-                              <SelectItem value="조선">조선</SelectItem>
-                              <SelectItem value="해양">해양</SelectItem>
-                              <SelectItem value="기타">기타</SelectItem>
+                              <SelectItem value="Shipbuild & Offshore">Shipbuild & Offshore</SelectItem>
+                              <SelectItem value="Wind Energy">Wind Energy</SelectItem>
+                              <SelectItem value="Power & Control Sys.">Power & Control Sys.</SelectItem>
+                              <SelectItem value="SHI NINGBO Co., LTD">SHI NINGBO Co., LTD</SelectItem>
+                              <SelectItem value="RONGCHENG Co.LTD">RONGCHENG Co.LTD</SelectItem>
+                              <SelectItem value="RONGCHENGGAYA Co.LTD">RONGCHENGGAYA Co.LTD</SelectItem>
+                              <SelectItem value="S&Sys">S&Sys</SelectItem>
+                              <SelectItem value="Energy & Infra Solut">Energy & Infra Solut</SelectItem>
+                              <SelectItem value="test pur.org222">test pur.org222</SelectItem>
                             </SelectContent>
                           </Select>
                           <FormMessage />
@@ -1138,12 +1128,12 @@ export function BiddingCreateDialog({ form, onSuccess }: BiddingCreateDialogProp
                     )}
                   />
 
-                  {isLoadingTemplate && (
+                  {/* {isLoadingTemplate && (
                     <div className="flex items-center justify-center p-4 text-sm text-muted-foreground">
                       <div className="animate-spin rounded-full h-4 w-4 border-b-2 border-gray-900 mr-2"></div>
                       입찰공고 템플릿을 불러오는 중...
                     </div>
-                  )}
+                  )} */}
                 </CardContent>
               </Card>
 
@@ -1174,14 +1164,16 @@ export function BiddingCreateDialog({ form, onSuccess }: BiddingCreateDialogProp
                     }}
                   >
                     {() => (
-                      <DropzoneZone className="flex justify-center h-32">
-                        <div className="flex items-center gap-6">
-                          <DropzoneUploadIcon />
-                          <div className="grid gap-0.5">
-                            <DropzoneTitle>파일을 드래그하여 업로드</DropzoneTitle>
+                      <DropzoneTrigger asChild>
+                        <DropzoneZone className="flex justify-center h-32">
+                          <div className="flex items-center gap-6">
+                            <DropzoneUploadIcon />
+                            <div className="grid gap-0.5">
+                              <DropzoneTitle>파일을 드래그하여 업로드</DropzoneTitle>
+                            </div>
                           </div>
-                        </div>
-                      </DropzoneZone>
+                        </DropzoneZone>
+                      </DropzoneTrigger>
                     )}
                   </Dropzone>
 
@@ -1246,14 +1238,16 @@ export function BiddingCreateDialog({ form, onSuccess }: BiddingCreateDialogProp
                     }}
                   >
                     {() => (
-                      <DropzoneZone className="flex justify-center h-32">
-                        <div className="flex items-center gap-6">
-                          <DropzoneUploadIcon />
-                          <div className="grid gap-0.5">
-                            <DropzoneTitle>파일을 드래그하여 업로드</DropzoneTitle>
+                      <DropzoneTrigger asChild>
+                        <DropzoneZone className="flex justify-center h-32">
+                          <div className="flex items-center gap-6">
+                            <DropzoneUploadIcon />
+                            <div className="grid gap-0.5">
+                              <DropzoneTitle>파일을 드래그하여 업로드</DropzoneTitle>
+                            </div>
                           </div>
-                        </div>
-                      </DropzoneZone>
+                        </DropzoneZone>
+                      </DropzoneTrigger>
                     )}
                   </Dropzone>
 
-- 
cgit v1.2.3

