diff options
Diffstat (limited to 'lib/docu-list-rule/combo-box-settings/table/combo-box-options-edit-sheet.tsx')
| -rw-r--r-- | lib/docu-list-rule/combo-box-settings/table/combo-box-options-edit-sheet.tsx | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/lib/docu-list-rule/combo-box-settings/table/combo-box-options-edit-sheet.tsx b/lib/docu-list-rule/combo-box-settings/table/combo-box-options-edit-sheet.tsx index 5732674e..4ac539d0 100644 --- a/lib/docu-list-rule/combo-box-settings/table/combo-box-options-edit-sheet.tsx +++ b/lib/docu-list-rule/combo-box-settings/table/combo-box-options-edit-sheet.tsx @@ -5,10 +5,17 @@ import { zodResolver } from "@hookform/resolvers/zod" import { useForm } from "react-hook-form" import { toast } from "sonner" import * as z from "zod" -import { Loader } from "lucide-react" import { Button } from "@/components/ui/button" import { + Sheet, + SheetContent, + SheetDescription, + SheetFooter, + SheetHeader, + SheetTitle, +} from "@/components/ui/sheet" +import { Form, FormControl, FormField, @@ -17,19 +24,12 @@ import { FormMessage, } from "@/components/ui/form" import { Input } from "@/components/ui/input" -import { - Sheet, - SheetContent, - SheetDescription, - SheetFooter, - SheetHeader, - SheetTitle, -} from "@/components/ui/sheet" import { updateComboBoxOption } from "../service" const updateOptionSchema = z.object({ - value: z.string().min(1, "값은 필수입니다."), + code: z.string().min(1, "코드는 필수입니다."), + remark: z.string().optional(), }) type UpdateOptionSchema = z.infer<typeof updateOptionSchema> @@ -63,14 +63,16 @@ export function ComboBoxOptionsEditSheet({ const form = useForm<UpdateOptionSchema>({ resolver: zodResolver(updateOptionSchema), defaultValues: { - value: "", + code: "", + remark: "", }, }) React.useEffect(() => { if (data) { form.reset({ - value: data.description, + code: data.code, + remark: data.remark || "", }) } }, [data, form]) @@ -82,7 +84,9 @@ export function ComboBoxOptionsEditSheet({ try { const result = await updateComboBoxOption({ id: data.id, - value: formData.value, + code: formData.code, + description: data.description, // 기존 description 유지 + remark: formData.remark, }) if (result.success) { @@ -117,12 +121,25 @@ export function ComboBoxOptionsEditSheet({ <form onSubmit={form.handleSubmit(handleSubmit)} className="space-y-4"> <FormField control={form.control} - name="value" + name="code" + render={({ field }) => ( + <FormItem> + <FormLabel>code</FormLabel> + <FormControl> + <Input {...field} placeholder="옵션 코드" /> + </FormControl> + <FormMessage /> + </FormItem> + )} + /> + <FormField + control={form.control} + name="remark" render={({ field }) => ( <FormItem> - <FormLabel>값</FormLabel> + <FormLabel>remark</FormLabel> <FormControl> - <Input {...field} placeholder="옵션 값" /> + <Input {...field} placeholder="비고 (선택사항)" /> </FormControl> <FormMessage /> </FormItem> @@ -133,9 +150,6 @@ export function ComboBoxOptionsEditSheet({ 취소 </Button> <Button type="submit" disabled={isPending || !form.formState.isValid}> - {isPending && ( - <Loader className="mr-2 size-4 animate-spin" aria-hidden="true" /> - )} 수정 </Button> </SheetFooter> |
