summaryrefslogtreecommitdiff
path: root/components/ship-vendor-document
diff options
context:
space:
mode:
Diffstat (limited to 'components/ship-vendor-document')
-rw-r--r--components/ship-vendor-document/new-revision-dialog.tsx41
-rw-r--r--components/ship-vendor-document/user-vendor-document-table-container.tsx20
2 files changed, 37 insertions, 24 deletions
diff --git a/components/ship-vendor-document/new-revision-dialog.tsx b/components/ship-vendor-document/new-revision-dialog.tsx
index bdbb1bc6..39025fa4 100644
--- a/components/ship-vendor-document/new-revision-dialog.tsx
+++ b/components/ship-vendor-document/new-revision-dialog.tsx
@@ -248,6 +248,14 @@ export function NewRevisionDialog({
// Serial No 쑰회
const fetchNextSerialNo = React.useCallback(async () => {
console.log('πŸ” fetchNextSerialNo called with documentId:', documentId)
+
+ // documentId μœ νš¨μ„± 검사
+ if (!documentId || documentId === undefined || documentId === null) {
+ console.warn('⚠️ Invalid documentId, using default serialNo: 1')
+ setNextSerialNo("1")
+ return
+ }
+
setIsLoadingSerialNo(true)
try {
const apiUrl = `/api/revisions/max-serial-no?documentId=${documentId}`
@@ -267,11 +275,16 @@ export function NewRevisionDialog({
setNextSerialNo(serialNoString)
console.log('πŸ” nextSerialNo state updated')
} else {
- console.error('πŸ” API call failed with status:', response.status)
+ const errorData = await response.json().catch(() => ({}))
+ console.error('πŸ” API call failed with status:', response.status, errorData)
+ // API μ‹€νŒ¨ μ‹œ κΈ°λ³Έκ°’ 1 μ‚¬μš©
+ console.warn('⚠️ Using default serialNo: 1')
+ setNextSerialNo("1")
}
} catch (error) {
console.error('❌ Failed to fetch serial no:', error)
// μ—λŸ¬ μ‹œ κΈ°λ³Έκ°’ 1 μ‚¬μš©
+ console.warn('⚠️ Using default serialNo: 1 due to error')
setNextSerialNo("1")
} finally {
setIsLoadingSerialNo(false)
@@ -280,12 +293,15 @@ export function NewRevisionDialog({
// Dialog 열릴 λ•Œ Serial No 쑰회
React.useEffect(() => {
- console.log('🎯 useEffect triggered - open:', open, 'documentId:', documentId)
- if (open && documentId) {
- console.log('🎯 Calling fetchNextSerialNo')
- fetchNextSerialNo()
- } else {
- console.log('🎯 Conditions not met for fetchNextSerialNo')
+ console.log('🎯 useEffect triggered - open:', open, 'documentId:', documentId, 'type:', typeof documentId)
+ if (open) {
+ if (documentId && typeof documentId === 'number' && documentId > 0) {
+ console.log('🎯 Calling fetchNextSerialNo')
+ fetchNextSerialNo()
+ } else {
+ console.warn('🎯 Invalid documentId, using default serialNo: 1')
+ setNextSerialNo("1")
+ }
}
}, [open, documentId, fetchNextSerialNo])
@@ -475,17 +491,12 @@ export function NewRevisionDialog({
<DialogDescription className="text-sm space-y-1">
<div>Document: {documentTitle}</div>
<div className="text-xs text-muted-foreground">
- Drawing Type: {drawingKind} | Serial No: {nextSerialNo}
- {isLoadingSerialNo && (
+ Drawing Type: {drawingKind} | Serial No: {isLoadingSerialNo ? (
<>
- <Loader2 className="inline-block ml-2 h-3 w-3 animate-spin" />
+ <Loader2 className="inline-block ml-1 h-3 w-3 animate-spin" />
<span className="ml-1">Loading...</span>
</>
- )}
- {/* λ””λ²„κ·Έμš© μž„μ‹œ ν‘œμ‹œ */}
- <div className="mt-1 text-xs text-orange-600">
- Debug: nextSerialNo={nextSerialNo}, isLoading={isLoadingSerialNo}
- </div>
+ ) : nextSerialNo}
</div>
</DialogDescription>
)}
diff --git a/components/ship-vendor-document/user-vendor-document-table-container.tsx b/components/ship-vendor-document/user-vendor-document-table-container.tsx
index 0c3390d1..1670732a 100644
--- a/components/ship-vendor-document/user-vendor-document-table-container.tsx
+++ b/components/ship-vendor-document/user-vendor-document-table-container.tsx
@@ -833,7 +833,7 @@ function SubTables() {
const handleDownloadFile = React.useCallback(async (attachment: AttachmentInfo) => {
try {
// 파일 경둜 처리
- let downloadPath = attachment.filePath
+ const downloadPath = attachment.filePath
// 곡용 λ‹€μš΄λ‘œλ“œ ν•¨μˆ˜ μ‚¬μš© (λ³΄μ•ˆ 검증, 파일 체크 λͺ¨λ‘ 포함)
const result = await downloadFile(downloadPath, attachment.fileName, {
@@ -1240,14 +1240,16 @@ function SubTables() {
</DialogContent>
</Dialog>
- <NewRevisionDialog
- open={newRevisionDialogOpen}
- onOpenChange={setNewRevisionDialogOpen}
- documentId={selectedDocument.documentId}
- documentTitle={selectedDocument.title}
- drawingKind={selectedDocument.drawingKind || 'B4'}
- onSuccess={handleRevisionUploadSuccess}
- />
+ {selectedDocument && (
+ <NewRevisionDialog
+ open={newRevisionDialogOpen}
+ onOpenChange={setNewRevisionDialogOpen}
+ documentId={selectedDocument.documentId}
+ documentTitle={selectedDocument.title}
+ drawingKind={selectedDocument.drawingKind || 'B4'}
+ onSuccess={handleRevisionUploadSuccess}
+ />
+ )}
{/* βœ… 리비전 μˆ˜μ • λ‹€μ΄μ–Όλ‘œκ·Έ */}
<EditRevisionDialog