diff --git a/src/app/(pages)/(albaform)/addform/page.tsx b/src/app/(pages)/(albaform)/addform/page.tsx index e6b399f0..c5dcebc7 100644 --- a/src/app/(pages)/(albaform)/addform/page.tsx +++ b/src/app/(pages)/(albaform)/addform/page.tsx @@ -23,7 +23,7 @@ export default function AddFormPage() { mode: "onChange", defaultValues: { isPublic: false, - hourlyWage: 10030, + hourlyWage: 0, isNegotiableWorkDays: false, workDays: [], workEndTime: "", @@ -35,7 +35,7 @@ export default function AddFormPage() { age: "", education: "", gender: "", - numberOfPositions: 0, + numberOfPositions: undefined, recruitmentEndDate: undefined, recruitmentStartDate: undefined, description: "", @@ -285,13 +285,13 @@ export default function AddFormPage() { onChange={handleOptionChange} currentParam={currentParam || ""} /> -
+
-
+
); } diff --git a/src/app/components/button/dropdown/InputDropdown.tsx b/src/app/components/button/dropdown/InputDropdown.tsx index 03e57aa4..5afb3f41 100644 --- a/src/app/components/button/dropdown/InputDropdown.tsx +++ b/src/app/components/button/dropdown/InputDropdown.tsx @@ -18,27 +18,29 @@ const InputDropdown = forwardRef( const [isOpen, setIsOpen] = useState(false); const [selectedValue, setSelectedValue] = useState(""); const [isCustomInput, setIsCustomInput] = useState(false); - const { setValue, getValues } = useFormContext(); + const { setValue, watch } = useFormContext(); const handleOptionClick = (option: string) => { if (option === "직접 입력") { setIsCustomInput(true); setSelectedValue(""); // 동적으로 받아온 name에 값 할당 -> 훅폼에 저장 - setValue(name, selectedValue); + setValue(name, selectedValue, { shouldDirty: true }); } else { setSelectedValue(option); setIsCustomInput(false); - setValue(name, option); + setValue(name, option, { shouldDirty: true }); setIsOpen(false); } }; // 작성중인 탭으로 다시 이동했을때 이전에 저장된 훅폼 데이터 연동 useEffect(() => { - const data = getValues(); - setSelectedValue(data.name || ""); - }, [getValues]); + const value = watch(name); // 동적으로 필드 값 가져오기 + if (value !== undefined) { + setSelectedValue(value); // 초기값 동기화 + } + }, [name, watch]); const textStyle = "text-base";