diff options
Diffstat (limited to 'lib/dolce/dialogs/b4-upload-validation-dialog.tsx')
| -rw-r--r-- | lib/dolce/dialogs/b4-upload-validation-dialog.tsx | 99 |
1 files changed, 48 insertions, 51 deletions
diff --git a/lib/dolce/dialogs/b4-upload-validation-dialog.tsx b/lib/dolce/dialogs/b4-upload-validation-dialog.tsx index f3a7c70a..05c1efd7 100644 --- a/lib/dolce/dialogs/b4-upload-validation-dialog.tsx +++ b/lib/dolce/dialogs/b4-upload-validation-dialog.tsx @@ -38,12 +38,12 @@ interface B4UploadValidationDialogProps { } /** - * B4 파일명 검증 함수 - * 형식: [버림] [문서번호토큰1] [문서번호토큰2] ... [리비전번호].[확장자] - * 예시: "testfile GTT DE 007 R01.pdf" → DrawingNo: "GTT-DE-007", RevNo: "R01" - * - 첫 번째 토큰은 버림 - * - 마지막 토큰은 RevNo - * - 중간 토큰들을 "-"로 연결하여 DrawingNo 생성 + * B4 file name validation function + * Format: [ignore] [document_number_token1] [document_number_token2] ... [revision_number].[extension] + * Example: "testfile GTT DE 007 R01.pdf" → DrawingNo: "GTT-DE-007", RevNo: "R01" + * - First token is ignored + * - Last token is RevNo + * - Middle tokens are joined with "-" to create DrawingNo */ export function validateB4FileName(fileName: string): { valid: boolean; @@ -51,47 +51,47 @@ export function validateB4FileName(fileName: string): { error?: string; } { try { - // 확장자 분리 + // Separate extension const lastDotIndex = fileName.lastIndexOf("."); if (lastDotIndex === -1) { return { valid: false, - error: "파일 확장자가 없습니다", + error: "File has no extension", }; } const nameWithoutExt = fileName.substring(0, lastDotIndex); - // 공백으로 분리 + // Split by spaces const parts = nameWithoutExt.split(" ").filter(p => p.trim() !== ""); - // 최소 3개 파트 필요: [버림], [문서번호토큰], [RevNo] + // At least 3 parts required: [ignore], [document_number_token], [RevNo] if (parts.length < 3) { return { valid: false, - error: `공백이 최소 2개 있어야 합니다 (현재: ${parts.length - 1}개). 형식: [버림] [문서번호토큰들...] [RevNo].[확장자]`, + error: `At least 2 spaces required (current: ${parts.length - 1}). Format: [ignore] [document_tokens...] [RevNo].[extension]`, }; } - // 첫 번째 토큰은 버림 - // 마지막 토큰은 RevNo - // 중간 토큰들을 "-"로 연결하여 DrawingNo 생성 + // First token is ignored + // Last token is RevNo + // Middle tokens are joined with "-" to create DrawingNo const revNo = parts[parts.length - 1]; const drawingTokens = parts.slice(1, parts.length - 1); const drawingNo = drawingTokens.join("-"); - // 필수 항목이 비어있지 않은지 확인 + // Check that required fields are not empty if (!drawingNo || drawingNo.trim() === "") { return { valid: false, - error: "도면번호(DrawingNo)가 비어있습니다", + error: "Drawing number (DrawingNo) is empty", }; } if (!revNo || revNo.trim() === "") { return { valid: false, - error: "리비전 번호(RevNo)가 비어있습니다", + error: "Revision number (RevNo) is empty", }; } @@ -106,13 +106,13 @@ export function validateB4FileName(fileName: string): { } catch (error) { return { valid: false, - error: error instanceof Error ? error.message : "알 수 없는 오류", + error: error instanceof Error ? error.message : "Unknown error", }; } } /** - * B4 업로드 전 파일 검증 다이얼로그 + * B4 file validation dialog before upload */ export function B4UploadValidationDialog({ open, @@ -141,45 +141,45 @@ export function B4UploadValidationDialog({ <Dialog open={open} onOpenChange={onOpenChange}> <DialogContent className="max-w-4xl max-h-[85vh] flex flex-col"> <DialogHeader className="flex-shrink-0"> - <DialogTitle>B4 일괄 업로드 검증</DialogTitle> + <DialogTitle>B4 Bulk Upload Validation</DialogTitle> <DialogDescription> - 선택한 파일의 파일명 형식과 매핑 가능 여부를 검증합니다 + Validates file name format and mapping availability for selected files </DialogDescription> </DialogHeader> <div className="space-y-4 overflow-auto flex-1 pr-2"> - {/* 요약 통계 */} + {/* Summary statistics */} <div className="grid grid-cols-4 gap-3"> <div className="rounded-lg border p-3"> - <div className="text-sm text-muted-foreground">전체</div> + <div className="text-sm text-muted-foreground">Total</div> <div className="text-2xl font-bold">{validationResults.length}</div> </div> <div className="rounded-lg border p-3 bg-green-50 dark:bg-green-950/30"> - <div className="text-sm text-green-600 dark:text-green-400">업로드 가능</div> + <div className="text-sm text-green-600 dark:text-green-400">Ready to Upload</div> <div className="text-2xl font-bold text-green-600 dark:text-green-400"> {validFiles.length} </div> </div> <div className="rounded-lg border p-3 bg-orange-50 dark:bg-orange-950/30"> - <div className="text-sm text-orange-600 dark:text-orange-400">도면 없음</div> + <div className="text-sm text-orange-600 dark:text-orange-400">Drawing Not Found</div> <div className="text-2xl font-bold text-orange-600 dark:text-orange-400"> {notFoundFiles.length} </div> </div> <div className="rounded-lg border p-3 bg-red-50 dark:bg-red-950/30"> - <div className="text-sm text-red-600 dark:text-red-400">형식 오류</div> + <div className="text-sm text-red-600 dark:text-red-400">Format Error</div> <div className="text-2xl font-bold text-red-600 dark:text-red-400"> {invalidFiles.length} </div> </div> </div> - {/* 경고 메시지 */} + {/* Warning messages */} {validFiles.length === 0 && ( <Alert variant="destructive"> <XCircle className="h-4 w-4" /> <AlertDescription> - 업로드 가능한 파일이 없습니다. 파일명 형식을 확인하거나 이미 매핑된 파일은 제외해주세요. + No files available for upload. Please check the file name format or exclude already mapped files. </AlertDescription> </Alert> )} @@ -188,20 +188,20 @@ export function B4UploadValidationDialog({ <Alert> <AlertCircle className="h-4 w-4" /> <AlertDescription> - 일부 파일에 문제가 있습니다. 업로드 가능한 {validFiles.length}개 파일만 업로드됩니다. + Some files have issues. Only {validFiles.length} file(s) will be uploaded. </AlertDescription> </Alert> )} - {/* 파일 목록 */} + {/* File list */} <div className="max-h-[50vh] overflow-auto rounded-md border p-4"> <div className="space-y-4"> - {/* 업로드 가능 파일 */} + {/* Files ready to upload */} {validFiles.length > 0 && ( <div className="space-y-2"> <h4 className="text-sm font-semibold text-green-600 dark:text-green-400 flex items-center gap-2"> <CheckCircle2 className="h-4 w-4" /> - 업로드 가능 ({validFiles.length}개) + Ready to Upload ({validFiles.length}) </h4> {validFiles.map((result, index) => ( <div @@ -216,7 +216,7 @@ export function B4UploadValidationDialog({ {result.parsed && ( <div className="flex flex-wrap gap-1 mt-2"> <Badge variant="outline" className="text-xs"> - 도면: {result.parsed.drawingNo} + Drawing: {result.parsed.drawingNo} </Badge> <Badge variant="outline" className="text-xs"> Rev: {result.parsed.revNo} @@ -236,12 +236,12 @@ export function B4UploadValidationDialog({ </div> )} - {/* 도면을 찾을 수 없는 파일 */} + {/* Files with drawing not found */} {notFoundFiles.length > 0 && ( <div className="space-y-2 mt-4"> <h4 className="text-sm font-semibold text-orange-600 dark:text-orange-400 flex items-center gap-2"> <XCircle className="h-4 w-4" /> - 도면을 찾을 수 없음 ({notFoundFiles.length}개) + Drawing Not Found ({notFoundFiles.length}) </h4> {notFoundFiles.map((result, index) => ( <div @@ -254,12 +254,12 @@ export function B4UploadValidationDialog({ {result.file.name} </div> <div className="text-xs text-orange-700 dark:text-orange-300 mt-1"> - ✗ 해당 도면번호가 프로젝트에 등록되어 있지 않습니다 + ✗ This drawing number is not registered in the project </div> {result.parsed && ( <div className="flex flex-wrap gap-1 mt-2"> <Badge variant="outline" className="text-xs"> - 도면: {result.parsed.drawingNo} + Drawing: {result.parsed.drawingNo} </Badge> <Badge variant="outline" className="text-xs"> Rev: {result.parsed.revNo} @@ -274,12 +274,12 @@ export function B4UploadValidationDialog({ </div> )} - {/* 형식 오류 파일 */} + {/* Files with format errors */} {invalidFiles.length > 0 && ( <div className="space-y-2 mt-4"> <h4 className="text-sm font-semibold text-red-600 dark:text-red-400 flex items-center gap-2"> <XCircle className="h-4 w-4" /> - 파일명 형식 오류 ({invalidFiles.length}개) + File Name Format Error ({invalidFiles.length}) </h4> {invalidFiles.map((result, index) => ( <div @@ -306,25 +306,22 @@ export function B4UploadValidationDialog({ </div> </div> - {/* 형식 안내 */} + {/* Format guide */} <div className="rounded-lg bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 p-3"> <div className="text-sm font-medium text-blue-900 dark:text-blue-100 mb-1"> - 📋 올바른 파일명 형식 + 📋 Correct File Name Format </div> <code className="text-xs text-blue-700 dark:text-blue-300"> - [버림] [문서번호토큰1] [문서번호토큰2] ... [RevNo].[확장자] + [fileName(without blanks)] [document_token1] [document_token2] ... [RevNo].[extension] </code> <div className="text-xs text-blue-600 dark:text-blue-400 mt-1"> - 예: testfile GTT DE 007 R01.pdf → DrawingNo: GTT-DE-007, Rev: R01 + Example: testfile GTT DE 007 R01.pdf → DrawingNo: GTT-DE-007, Rev: R01 </div> <div className="text-xs text-blue-600 dark:text-blue-400 mt-1"> - ※ 첫 번째 단어는 무시됩니다 + ※ The last word is the revision number (RevNo) </div> <div className="text-xs text-blue-600 dark:text-blue-400 mt-1"> - ※ 마지막 단어는 리비전 번호(RevNo)입니다 - </div> - <div className="text-xs text-blue-600 dark:text-blue-400 mt-1"> - ※ 중간의 모든 단어는 "-"로 연결되어 문서번호(DrawingNo)가 됩니다 + ※ All middle words are connected with "-" to become the document number (DrawingNo) </div> </div> </div> @@ -335,7 +332,7 @@ export function B4UploadValidationDialog({ onClick={handleCancel} disabled={isUploading} > - 취소 + Cancel </Button> <Button onClick={handleUpload} @@ -344,12 +341,12 @@ export function B4UploadValidationDialog({ {isUploading ? ( <> <div className="animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2" /> - 업로드 중... + Uploading... </> ) : ( <> <Upload className="h-4 w-4 mr-2" /> - 업로드 ({validFiles.length}개) + Upload ({validFiles.length}) </> )} </Button> |
