From 59b5715ebb3e1fd7bd4eb02ce50399715734f865 Mon Sep 17 00:00:00 2001
From: 0-Zz-ang <s1998319@gmail.com>
Date: Mon, 4 Aug 2025 14:59:15 +0900
Subject: (박서영) docu-list-rule detail sheet 컴포넌트 추가 및 검색 필터 기능
 오류 수정
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../table/combo-box-options-add-dialog.tsx         | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

(limited to 'lib/docu-list-rule/combo-box-settings/table/combo-box-options-add-dialog.tsx')

diff --git a/lib/docu-list-rule/combo-box-settings/table/combo-box-options-add-dialog.tsx b/lib/docu-list-rule/combo-box-settings/table/combo-box-options-add-dialog.tsx
index a5a8af2f..049e2c1a 100644
--- a/lib/docu-list-rule/combo-box-settings/table/combo-box-options-add-dialog.tsx
+++ b/lib/docu-list-rule/combo-box-settings/table/combo-box-options-add-dialog.tsx
@@ -31,7 +31,7 @@ import { createComboBoxOption } from "../service"
 
 const createOptionSchema = z.object({
   code: z.string().min(1, "코드는 필수입니다."),
-  description: z.string().default("-"),
+  description: z.string().default(""),
   remark: z.string().optional(),
 })
 
@@ -50,18 +50,24 @@ export function ComboBoxOptionsAddDialog({ codeGroupId, onSuccess }: ComboBoxOpt
     resolver: zodResolver(createOptionSchema),
     defaultValues: {
       code: "",
-      description: "-",
+      description: "",
       remark: "",
     },
   })
 
+  // 코드 입력 시 자동으로 description에 반영
+  const handleCodeChange = (value: string) => {
+    form.setValue("code", value)
+    form.setValue("description", value) // 코드값을 description에도 자동 설정
+  }
+
   const handleSubmit = (data: CreateOptionSchema) => {
     startTransition(async () => {
       try {
         const result = await createComboBoxOption({
           codeGroupId,
           code: data.code,
-          description: data.description || "-",
+          description: data.description || data.code, // description이 비어있으면 code 사용
           remark: data.remark,
         })
 
@@ -109,7 +115,11 @@ export function ComboBoxOptionsAddDialog({ codeGroupId, onSuccess }: ComboBoxOpt
                 <FormItem>
                   <FormLabel>코드</FormLabel>
                   <FormControl>
-                    <Input {...field} placeholder="옵션 코드" />
+                    <Input 
+                      {...field} 
+                      placeholder="옵션 코드" 
+                      onChange={(e) => handleCodeChange(e.target.value)}
+                    />
                   </FormControl>
                   <FormMessage />
                 </FormItem>
@@ -120,9 +130,9 @@ export function ComboBoxOptionsAddDialog({ codeGroupId, onSuccess }: ComboBoxOpt
               name="description"
               render={({ field }) => (
                 <FormItem>
-                  <FormLabel>값</FormLabel>
+                  <FormLabel>Description</FormLabel>
                   <FormControl>
-                    <Input {...field} placeholder="옵션 값" />
+                    <Input {...field} placeholder="옵션 설명" />
                   </FormControl>
                   <FormMessage />
                 </FormItem>
-- 
cgit v1.2.3

