@@ -4,13 +4,13 @@ import { useRouter, useSearchParams } from "next/navigation";
44import { FormProvider , useForm } from "react-hook-form" ;
55import axios from "axios" ;
66import TabMenuDropdown from "@/app/components/button/dropdown/TabMenuDropdown" ;
7- import RecruitCondition from "./RecruitCondition" ;
87import Button from "@/app/components/button/default/Button" ;
98import { toast } from "react-hot-toast" ;
109import { useMutation } from "@tanstack/react-query" ;
1110import { useUpdateProfile } from "@/hooks/queries/user/me/useUpdateProfile" ;
12- import RecruitContent from "./RecruitContent" ;
13- import WorkCondition from "./WorkCondition" ;
11+ import RecruitContentSection from "./RecruitContentSection" ;
12+ import RecruitConditionSection from "./RecruitConditionSection" ;
13+ import WorkConditionSection from "./WorkConditionSection" ;
1414
1515interface SubmitFormDataType {
1616 isPublic : boolean ;
@@ -66,13 +66,12 @@ export default function AddFormPage() {
6666
6767 const {
6868 setValue,
69- getValues,
7069 handleSubmit,
7170 formState : { isDirty, isValid } ,
7271 } = methods ;
7372
7473 // ํ
ํผ์์ ๊ด๋ฆฌํ๋ ์ ์ฒด ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ค๋ ํจ์
75- const currentValues : SubmitFormDataType = getValues ( ) ;
74+ const currentValues : SubmitFormDataType = methods . watch ( ) ;
7675
7776 // ์ด๋ฏธ์ง ์
๋ก๋ api ์ฒ๋ฆฌ๋ฅผ ์ํด ๋ณ๋ ๋ณ์์ ํ ๋น
7877 const imageFiles = currentValues . imageFiles ;
@@ -135,17 +134,17 @@ export default function AddFormPage() {
135134 "๋ชจ์ง ์กฐ๊ฑด" : "recruit-condition" ,
136135 "๊ทผ๋ฌด ์กฐ๊ฑด" : "work-condition" ,
137136 } [ option ] ;
138- router . replace ( `/addform?tab=${ params } ` ) ;
137+ router . push ( `/addform?tab=${ params } ` ) ;
139138 } ;
140139
141140 const renderChildren = ( ) => {
142141 switch ( selectedOption ) {
143142 case "๋ชจ์ง ๋ด์ฉ" :
144- return < RecruitContent key = "recruitContent" /> ;
143+ return < RecruitContentSection key = "recruitContent" /> ;
145144 case "๋ชจ์ง ์กฐ๊ฑด" :
146- return < RecruitCondition key = "recruitCondition" /> ;
145+ return < RecruitConditionSection key = "recruitCondition" /> ;
147146 case "๊ทผ๋ฌด ์กฐ๊ฑด" :
148- return < WorkCondition key = "workCondition" /> ;
147+ return < WorkConditionSection key = "workCondition" /> ;
149148 default :
150149 return < > </ > ;
151150 }
@@ -204,33 +203,27 @@ export default function AddFormPage() {
204203 window . localStorage . setItem ( "tempAddFormData" , JSON . stringify ( currentValues ) ) ;
205204 }
206205 toast . success ( "์์ ์ ์ฅ๋์์ต๋๋ค." ) ;
207- // console.log("์์์ ์ฅ ๋ฐ์ดํฐ", currentValues);
206+ console . log ( "์์์ ์ฅ ๋ฐ์ดํฐ" , currentValues ) ;
208207 } ;
209208
210209 // ๊ฐ๊ฐ์ ํญ ์์ฑ์ค ์ฌ๋ถ
211210 const isEditingRecruitContent =
212- currentValues . title !== "" ||
213- currentValues . description !== "" ||
214- currentValues . recruitmentStartDate !== "" ||
215- currentValues . imageUrls
211+ currentValues . title !== "" || currentValues . description !== "" || currentValues . recruitmentStartDate !== undefined
216212 ? true
217213 : false ;
218214 const isEditingRecruitCondition =
219- currentValues . gender ||
220- currentValues . numberOfPositions ||
221- currentValues . education ||
222- currentValues . age ||
223- currentValues . preferred
215+ currentValues . gender !== "" ||
216+ currentValues . numberOfPositions !== 0 ||
217+ currentValues . education !== "" ||
218+ currentValues . age !== "" ||
219+ currentValues . preferred !== ""
224220 ? true
225221 : false ;
226222 const isEditingWorkCondition =
227- currentValues . location ||
228- currentValues . workDays ||
229- currentValues . workStartTime ||
230- currentValues . workStartDate ||
231- currentValues . hourlyWage ||
232- currentValues . isNegotiableWorkDays ||
233- currentValues . isPublic
223+ currentValues . location !== "" ||
224+ currentValues . workStartTime !== "" ||
225+ currentValues . workStartDate !== "" ||
226+ currentValues . hourlyWage > 0
234227 ? true
235228 : false ;
236229
@@ -242,7 +235,7 @@ export default function AddFormPage() {
242235 options = { [
243236 {
244237 label : "๋ชจ์ง ๋ด์ฉ" ,
245- isEditing : isEditingRecruitContent || initialLoad || currentParam === "recruit-condition " ,
238+ isEditing : isEditingRecruitContent || initialLoad || currentParam === "recruit-content " ,
246239 } ,
247240 { label : "๋ชจ์ง ์กฐ๊ฑด" , isEditing : isEditingRecruitCondition || currentParam === "recruit-condition" } ,
248241 { label : "๊ทผ๋ฌด ์กฐ๊ฑด" , isEditing : isEditingWorkCondition || currentParam === "work-condition" } ,
0 commit comments