diff options
Diffstat (limited to 'lib/bidding/vendor/components')
| -rw-r--r-- | lib/bidding/vendor/components/simple-file-upload.tsx | 20 |
1 files changed, 16 insertions, 4 deletions
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: '다운로드 실패', |
