From ff902243a658067fae858a615c0629aa2e0a4837 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Wed, 11 Jun 2025 12:18:38 +0000 Subject: (대표님) 20250611 21시 15분 OCR 등 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/welding/table/ocr-table-toolbar-actions.tsx | 96 +++++++++++++++++++------ 1 file changed, 76 insertions(+), 20 deletions(-) (limited to 'lib/welding/table/ocr-table-toolbar-actions.tsx') diff --git a/lib/welding/table/ocr-table-toolbar-actions.tsx b/lib/welding/table/ocr-table-toolbar-actions.tsx index 001b21cb..6c6d0637 100644 --- a/lib/welding/table/ocr-table-toolbar-actions.tsx +++ b/lib/welding/table/ocr-table-toolbar-actions.tsx @@ -39,6 +39,24 @@ export function OcrTableToolbarActions({ table }: OcrTableToolbarActionsProps) { const [selectedFile, setSelectedFile] = React.useState(null) const fileInputRef = React.useRef(null) + // 다이얼로그 닫기 핸들러 - 업로드 중에는 닫기 방지 + const handleDialogOpenChange = (open: boolean) => { + // 다이얼로그를 닫으려고 할 때 + if (!open) { + // 업로드가 진행 중이면 닫기를 방지 + if (isUploading && uploadProgress?.stage !== "complete") { + toast.warning("Cannot close while processing. Please wait for completion.", { + description: "OCR processing is in progress..." + }) + return // 다이얼로그를 닫지 않음 + } + + // 업로드가 진행 중이 아니거나 완료되었으면 초기화 후 닫기 + resetUpload() + } + + setIsUploadDialogOpen(open) + } const handleFileSelect = (event: React.ChangeEvent) => { const file = event.target.files?.[0] @@ -142,11 +160,7 @@ export function OcrTableToolbarActions({ table }: OcrTableToolbarActionsProps) { // 성공 후 다이얼로그 닫기 및 상태 초기화 setTimeout(() => { setIsUploadDialogOpen(false) - setSelectedFile(null) - setUploadProgress(null) - if (fileInputRef.current) { - fileInputRef.current.value = '' - } + resetUpload() // 테이블 새로고침 window.location.reload() @@ -177,21 +191,60 @@ export function OcrTableToolbarActions({ table }: OcrTableToolbarActionsProps) { } } + // Cancel 버튼 핸들러 + const handleCancelClick = () => { + if (isUploading && uploadProgress?.stage !== "complete") { + // 업로드 진행 중이면 취소 불가능 메시지 + toast.warning("Cannot cancel while processing. Please wait for completion.", { + description: "OCR processing cannot be interrupted safely." + }) + } else { + // 업로드 중이 아니거나 완료되었으면 다이얼로그 닫기 + setIsUploadDialogOpen(false) + resetUpload() + } + } + return (
{/* OCR 업로드 다이얼로그 */} - + - + { + if (isUploading && uploadProgress?.stage !== "complete") { + e.preventDefault() + toast.warning("Cannot close while processing. Please wait for completion.") + } + }} + // 업로드 중에는 외부 클릭으로도 닫기 방지 + onInteractOutside={(e) => { + if (isUploading && uploadProgress?.stage !== "complete") { + e.preventDefault() + toast.warning("Cannot close while processing. Please wait for completion.") + } + }} + > - Upload Document for OCR + + Upload Document for OCR + {/* 업로드 중일 때 로딩 인디케이터 표시 */} + {isUploading && uploadProgress?.stage !== "complete" && ( + + )} + - Upload a PDF or image file to extract table data using OCR technology. + {isUploading && uploadProgress?.stage !== "complete" + ? "Processing in progress. Please do not close this dialog." + : "Upload a PDF or image file to extract table data using OCR technology." + } @@ -239,6 +292,16 @@ export function OcrTableToolbarActions({ table }: OcrTableToolbarActionsProps) {

{uploadProgress.message}

+ + {/* 진행 중일 때 안내 메시지 */} + {isUploading && uploadProgress.stage !== "complete" && ( +
+ +

+ Please wait... This dialog will close automatically when complete. +

+
+ )}
)} @@ -247,18 +310,10 @@ export function OcrTableToolbarActions({ table }: OcrTableToolbarActionsProps) {