From c54a2445b6285d06c0ce3afa1cd3aa6aecf6de94 Mon Sep 17 00:00:00 2001
From: joonhoekim <26rote@gmail.com>
Date: Mon, 24 Nov 2025 20:13:50 +0900
Subject: (김준회) dolce rebuild: i18n 지원
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/dolce/dialogs/add-detail-drawing-dialog.tsx | 85 +++++++++++--------------
 1 file changed, 36 insertions(+), 49 deletions(-)

(limited to 'lib/dolce/dialogs/add-detail-drawing-dialog.tsx')

diff --git a/lib/dolce/dialogs/add-detail-drawing-dialog.tsx b/lib/dolce/dialogs/add-detail-drawing-dialog.tsx
index 2454b1ba..48614ecf 100644
--- a/lib/dolce/dialogs/add-detail-drawing-dialog.tsx
+++ b/lib/dolce/dialogs/add-detail-drawing-dialog.tsx
@@ -26,6 +26,12 @@ import { v4 as uuidv4 } from "uuid";
 import { useFileUploadWithProgress } from "../hooks/use-file-upload-with-progress";
 import { uploadFilesWithProgress } from "../utils/upload-with-progress";
 import { FileUploadProgressList } from "../components/file-upload-progress-list";
+import { 
+  getB3DrawingUsageOptions, 
+  getB3RegisterKindOptions,
+  getB4DrawingUsageOptions,
+  getB4RegisterKindOptions
+} from "../utils/code-translator";
 
 interface AddDetailDrawingDialogProps {
   open: boolean;
@@ -36,38 +42,10 @@ interface AddDetailDrawingDialogProps {
   userName: string;
   userEmail: string;
   onComplete: () => void;
-  drawingKind: "B3" | "B4"; // 추가
+  drawingKind: "B3" | "B4";
+  lng?: string; // i18n support
 }
 
-// B3 벤더의 선택 옵션
-const B3_DRAWING_USAGE_OPTIONS = [
-  { value: "APP", label: "APPROVAL (승인용)" },
-  { value: "WOR", label: "WORKING (작업용)" },
-];
-
-const B3_REGISTER_KIND_OPTIONS: Record<string, Array<{ value: string; label: string; revisionRule: string }>> = {
-  APP: [
-    { value: "APPR", label: "승인용 도면 (Full)", revisionRule: "예: A, B, C 또는 R00, R01, R02" },
-    { value: "APPR-P", label: "승인용 도면 (Partial)", revisionRule: "예: A, B, C 또는 R00, R01, R02" },
-  ],
-  WOR: [
-    { value: "WORK", label: "작업용 입수도면 (Full)", revisionRule: "예: A, B, C 또는 R00, R01, R02" },
-    { value: "WORK-P", label: "작업용 입수도면 (Partial)", revisionRule: "예: A, B, C 또는 R00, R01, R02" },
-  ],
-};
-
-// B4 벤더(GTT)의 선택 옵션
-const B4_DRAWING_USAGE_OPTIONS = [
-  { value: "REC", label: "RECEIVE (입수용)" },
-];
-
-const B4_REGISTER_KIND_OPTIONS: Record<string, Array<{ value: string; label: string; revisionRule: string }>> = {
-  REC: [
-    { value: "RECP", label: "Pre. 도면입수", revisionRule: "예: R00, R01, R02, R03" },
-    { value: "RECW", label: "Working 도면입수", revisionRule: "예: R00, R01, R02, R03" },
-  ],
-};
-
 export function AddDetailDrawingDialog({
   open,
   onOpenChange,
@@ -78,6 +56,7 @@ export function AddDetailDrawingDialog({
   userEmail,
   onComplete,
   drawingKind,
+  lng = "ko",
 }: AddDetailDrawingDialogProps) {
   const [drawingUsage, setDrawingUsage] = useState<string>("");
   const [registerKind, setRegisterKind] = useState<string>("");
@@ -85,6 +64,21 @@ export function AddDetailDrawingDialog({
   const [revisionError, setRevisionError] = useState<string>("");
   const [isSubmitting, setIsSubmitting] = useState(false);
 
+  // 옵션 생성 (다국어 지원)
+  const drawingUsageOptions = drawingKind === "B3" 
+    ? getB3DrawingUsageOptions(lng)
+    : getB4DrawingUsageOptions(lng);
+
+  const registerKindOptions = drawingKind === "B3"
+    ? getB3RegisterKindOptions(drawingUsage, lng).map(opt => ({
+        ...opt,
+        revisionRule: lng === "ko" ? "예: A, B, C 또는 R00, R01, R02" : "e.g. A, B, C or R00, R01, R02"
+      }))
+    : getB4RegisterKindOptions(drawingUsage, lng).map(opt => ({
+        ...opt,
+        revisionRule: lng === "ko" ? "예: R00, R01, R02, R03" : "e.g. R00, R01, R02, R03"
+      }));
+
   // 파일 업로드 훅 사용 (진행도 추적)
   const {
     fileProgresses,
@@ -118,20 +112,13 @@ export function AddDetailDrawingDialog({
     return "올바른 형식이 아닙니다 (A-Z 또는 R00-R99)";
   };
 
-  // Revision 입력 핸들러 (자동 변환 포함)
+  // Revision 입력 핸들러
   const handleRevisionChange = (value: string) => {
-    let processedValue = value.toUpperCase().trim();
-
-    // R1~R9 입력시 R01~R09로 자동 변환
-    const rNumberMatch = processedValue.match(/^R(\d)$/);
-    if (rNumberMatch) {
-      processedValue = `R0${rNumberMatch[1]}`;
-    }
-
+    const processedValue = value.toUpperCase();
     setRevision(processedValue);
 
     // 값이 있을 때만 validation
-    if (processedValue) {
+    if (processedValue.trim()) {
       const error = validateRevision(processedValue);
       setRevisionError(error);
     } else {
@@ -280,17 +267,17 @@ export function AddDetailDrawingDialog({
     setRevisionError("");
   };
 
-  // 현재 선택 가능한 DrawingUsage 및 RegisterKind 옵션
-  const drawingUsageOptions = drawingKind === "B4" ? B4_DRAWING_USAGE_OPTIONS : B3_DRAWING_USAGE_OPTIONS;
-  const registerKindOptionsMap = drawingKind === "B4" ? B4_REGISTER_KIND_OPTIONS : B3_REGISTER_KIND_OPTIONS;
-  
-  const registerKindOptions = drawingUsage
-    ? registerKindOptionsMap[drawingUsage] || []
-    : [];
-
   // 선택된 RegisterKind의 Revision Rule
   const revisionRule = registerKindOptions.find((opt) => opt.value === registerKind)?.revisionRule || "";
 
+  // 추가 버튼 활성화 조건
+  const isFormValid = 
+    drawingUsage.trim() !== "" &&
+    registerKind.trim() !== "" &&
+    revision.trim() !== "" &&
+    !revisionError &&
+    files.length > 0;
+
   return (
     <Dialog open={open} onOpenChange={onOpenChange}>
       <DialogContent className="max-w-2xl">
@@ -467,7 +454,7 @@ export function AddDetailDrawingDialog({
           <Button variant="outline" onClick={handleCancel} disabled={isSubmitting}>
             취소
           </Button>
-          <Button onClick={handleSubmit} disabled={isSubmitting}>
+          <Button onClick={handleSubmit} disabled={isSubmitting || !isFormValid}>
             {isSubmitting ? "처리 중..." : "추가"}
           </Button>
         </DialogFooter>
-- 
cgit v1.2.3

