From cbb4c7fe0b94459162ad5e998bc05cd293e0ff96 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 11 Aug 2025 09:02:00 +0000
Subject: (대표님) 입찰, EDP 변경사항 대응, spreadJS 오류 수정, 벤더실사 수정
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 components/form-data/update-form-sheet.tsx | 55 ++++++++++++++++++------------
 1 file changed, 34 insertions(+), 21 deletions(-)

(limited to 'components/form-data/update-form-sheet.tsx')

diff --git a/components/form-data/update-form-sheet.tsx b/components/form-data/update-form-sheet.tsx
index 5666a116..91cb7a07 100644
--- a/components/form-data/update-form-sheet.tsx
+++ b/components/form-data/update-form-sheet.tsx
@@ -45,6 +45,8 @@ import {
 import { DataTableColumnJSON } from "./form-data-table-columns";
 import { updateFormDataInDB } from "@/lib/forms/services";
 import { cn } from "@/lib/utils";
+import { useParams } from "next/navigation";
+import { useTranslation } from "@/i18n/client";
 
 /** =============================================================
  *  🔄  UpdateTagSheet with grouped fields by `head` property
@@ -86,6 +88,10 @@ export function UpdateTagSheet({
   const [isPending, startTransition] = React.useTransition();
   const router = useRouter();
 
+  const params = useParams();
+  const lng = (params?.lng as string) || "ko";
+  const { t } = useTranslation(lng, "engineering");
+
   /* ----------------------------------------------------------------
    * 1️⃣  Editable‑field helpers (unchanged)
    * --------------------------------------------------------------*/
@@ -105,17 +111,17 @@ export function UpdateTagSheet({
   const isFieldReadOnly = React.useCallback((column: DataTableColumnJSON) => !isFieldEditable(column), [isFieldEditable]);
 
   const getReadOnlyReason = React.useCallback((column: DataTableColumnJSON) => {
-    if (column.shi) return "SHI‑only field (managed by SHI system)";
+    if (column.shi) return t("updateTagSheet.readOnlyReasons.shiOnly");
     if (column.key !== "TAG_NO" && column.key !== "TAG_DESC") {
       if (!rowData?.TAG_NO || !editableFieldsMap.has(rowData.TAG_NO)) {
-        return "No editable fields information for this TAG";
+        return t("updateTagSheet.readOnlyReasons.noEditableFields");
       }
       if (!editableFields.includes(column.key)) {
-        return "Not editable for this TAG class";
+        return t("updateTagSheet.readOnlyReasons.notEditableForTag");
       }
     }
-    return "Read‑only field";
-  }, [rowData?.TAG_NO, editableFieldsMap, editableFields]);
+    return t("updateTagSheet.readOnlyReasons.readOnly");
+  }, [rowData?.TAG_NO, editableFieldsMap, editableFields, t]);
 
   /* ----------------------------------------------------------------
    * 2️⃣  Zod dynamic schema & form state (unchanged)
@@ -220,7 +226,7 @@ export function UpdateTagSheet({
           return;
         }
 
-        toast.success("Updated successfully!");
+        toast.success(t("updateTagSheet.messages.updateSuccess"));
 
         const updatedData = { ...rowData, ...finalValues, TAG_NO: rowData?.TAG_NO };
         onUpdateSuccess?.(updatedData);
@@ -228,7 +234,7 @@ export function UpdateTagSheet({
         onOpenChange(false);
       } catch (error) {
         console.error("Error updating form data:", error);
-        toast.error("An unexpected error occurred while updating");
+        toast.error(t("updateTagSheet.messages.updateError"));
       }
     });
   }
@@ -243,15 +249,18 @@ export function UpdateTagSheet({
       <SheetContent className="sm:max-w-xl md:max-w-3xl lg:max-w-4xl xl:max-w-5xl flex flex-col">
         <SheetHeader className="text-left">
           <SheetTitle>
-            Update Row – {rowData?.TAG_NO || "Unknown TAG"}
+            {t("updateTagSheet.title")} – {rowData?.TAG_NO || t("updateTagSheet.unknownTag")}
           </SheetTitle>
           <SheetDescription>
-            Modify the fields below and save changes. Fields with
-            <LockIcon className="inline h-3 w-3 mx-1" /> are read‑only.
+            {t("updateTagSheet.description")}
+            <LockIcon className="inline h-3 w-3 mx-1" />
+            {t("updateTagSheet.readOnlyIndicator")}
             <br />
             <span className="text-sm text-green-600">
-              {editableFieldCount} of {columns.length} fields are editable for
-              this TAG.
+              {t("updateTagSheet.editableFieldsCount", { 
+                editableCount: editableFieldCount, 
+                totalCount: columns.length 
+              })}
             </span>
           </SheetDescription>
         </SheetHeader>
@@ -303,7 +312,7 @@ export function UpdateTagSheet({
                                     value={field.value ?? ""}
                                     className={cn(
                                       isReadOnly &&
-                                        "bg-gray-100 text-gray-600 cursor-not-allowed border-gray-300",
+                                      "bg-gray-100 text-gray-600 cursor-not-allowed border-gray-300",
                                     )}
                                   />
                                 </FormControl>
@@ -337,17 +346,20 @@ export function UpdateTagSheet({
                                         "w-full justify-between",
                                         !field.value && "text-muted-foreground",
                                         isReadOnly &&
-                                          "bg-gray-100 text-gray-600 cursor-not-allowed border-gray-300",
+                                        "bg-gray-100 text-gray-600 cursor-not-allowed border-gray-300",
                                       )}
                                     >
-                                      {field.value ? col.options?.find((o) => o === field.value) : "Select an option"}
+                                      {field.value ? 
+                                        col.options?.find((o) => o === field.value) : 
+                                        t("updateTagSheet.selectOption")
+                                      }
                                       <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
                                     </Button>
                                   </PopoverTrigger>
                                   <PopoverContent className="w-full p-0">
                                     <Command>
-                                      <CommandInput placeholder="Search options..." />
-                                      <CommandEmpty>No option found.</CommandEmpty>
+                                      <CommandInput placeholder={t("updateTagSheet.searchOptions")} />
+                                      <CommandEmpty>{t("updateTagSheet.noOptionFound")}</CommandEmpty>
                                       <CommandList>
                                         <CommandGroup>
                                           {col.options?.map((opt) => (
@@ -391,7 +403,7 @@ export function UpdateTagSheet({
                                   {...field}
                                   className={cn(
                                     isReadOnly &&
-                                      "bg-gray-100 text-gray-600 cursor-not-allowed border-gray-300",
+                                    "bg-gray-100 text-gray-600 cursor-not-allowed border-gray-300",
                                   )}
                                 />
                               </FormControl>
@@ -415,11 +427,12 @@ export function UpdateTagSheet({
             <SheetFooter className="gap-2 pt-2">
               <SheetClose asChild>
                 <Button type="button" variant="outline">
-                  Cancel
+                  {t("buttons.cancel")}
                 </Button>
               </SheetClose>
               <Button type="submit" disabled={isPending}>
-                {isPending && <Loader className="mr-2 h-4 w-4 animate-spin" />}Save
+                {isPending && <Loader className="mr-2 h-4 w-4 animate-spin" />}
+                {t("buttons.save")}
               </Button>
             </SheetFooter>
           </form>
@@ -427,4 +440,4 @@ export function UpdateTagSheet({
       </SheetContent>
     </Sheet>
   );
-}
+}
\ No newline at end of file
-- 
cgit v1.2.3

