From 86b1fd1cc801f45642f84d24c0b5c84368454ff0 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Tue, 9 Sep 2025 10:34:05 +0000
Subject: (최겸) 구매 입찰 사전견적, 입찰, 낙찰, 유찰, 재입찰 기능 개발
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/bidding/vendor/components/simple-file-upload.tsx | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

(limited to 'lib/bidding/vendor/components/simple-file-upload.tsx')

diff --git a/lib/bidding/vendor/components/simple-file-upload.tsx b/lib/bidding/vendor/components/simple-file-upload.tsx
index b1eb8b8f..58b60bdf 100644
--- a/lib/bidding/vendor/components/simple-file-upload.tsx
+++ b/lib/bidding/vendor/components/simple-file-upload.tsx
@@ -65,15 +65,23 @@ export function SimpleFileUpload({
     try {
       setIsLoading(true)
       const docs = await getPreQuoteDocuments(biddingId, companyId)
+      
+      // docs가 undefined이거나 배열이 아닌 경우 빈 배열로 처리
+      if (!docs || !Array.isArray(docs)) {
+        setDocuments([])
+        return
+      }
+      
       // Date를 string으로 변환
       const mappedDocs = docs.map(doc => ({
         ...doc,
-        uploadedAt: doc.uploadedAt.toString(),
+        uploadedAt: doc.uploadedAt?.toString() || '',
         uploadedBy: doc.uploadedBy || ''
       }))
       setDocuments(mappedDocs)
     } catch (error) {
       console.error('Failed to load documents:', error)
+      setDocuments([]) // 에러 시에도 빈 배열로 설정
       toast({
         title: '오류',
         description: '업로드된 문서 목록을 불러오는데 실패했습니다.',
@@ -155,9 +163,13 @@ export function SimpleFileUpload({
       
       if (result.success) {
         try {
-          await downloadFile(result.document?.filePath, result.document?.originalFileName, {
-            showToast: true
-          })
+          if (result.document?.filePath && result.document?.originalFileName) {
+            await downloadFile(result.document.filePath, result.document.originalFileName, {
+              showToast: true
+            })
+          } else {
+            throw new Error('파일 정보가 없습니다.')
+          }
         } catch (error) {
           toast({
             title: '다운로드 실패',
-- 
cgit v1.2.3

