Skip to content

Commit 0e87c7b

Browse files
authored
Merge pull request #124 from FE9-2/feat/albaform/edit
Fix : ํผ ๊ด€๋ จ ์ˆ˜์ •
2 parents f654aa3 + 3b9932b commit 0e87c7b

File tree

7 files changed

+64
-52
lines changed

7 files changed

+64
-52
lines changed

โ€Žsrc/app/(pages)/(albaform)/addform/page.tsxโ€Ž

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default function AddFormPage() {
2323
mode: "onChange",
2424
defaultValues: {
2525
isPublic: false,
26-
hourlyWage: 10030,
26+
hourlyWage: 0,
2727
isNegotiableWorkDays: false,
2828
workDays: [],
2929
workEndTime: "",
@@ -35,7 +35,7 @@ export default function AddFormPage() {
3535
age: "",
3636
education: "",
3737
gender: "",
38-
numberOfPositions: 0,
38+
numberOfPositions: undefined,
3939
recruitmentEndDate: undefined,
4040
recruitmentStartDate: undefined,
4141
description: "",
@@ -285,13 +285,13 @@ export default function AddFormPage() {
285285
onChange={handleOptionChange}
286286
currentParam={currentParam || ""}
287287
/>
288-
<div className="absolute -bottom-[160px] mb-20 flex flex-col gap-2 lg:relative lg:bottom-0 lg:mb-0">
288+
<div className="absolute -bottom-[160px] mb-20 flex w-full flex-col gap-2 lg:relative lg:bottom-0 lg:mb-0">
289289
<Button
290290
type="button"
291291
variant="outlined"
292292
width="md"
293293
color="orange"
294-
className="h-[58px] border bg-background-100 lg:h-[72px] lg:text-xl lg:leading-8"
294+
className="lg: h-[58px] w-[320px] border bg-background-100 lg:h-[72px] lg:w-full lg:text-xl lg:leading-8"
295295
onClick={() => onTempSave()}
296296
>
297297
์ž„์‹œ ์ €์žฅ
@@ -301,7 +301,7 @@ export default function AddFormPage() {
301301
variant="solid"
302302
width="md"
303303
color="orange"
304-
className="h-[58px] lg:h-[72px] lg:text-xl lg:leading-8"
304+
className="lg: h-[58px] w-[320px] lg:h-[72px] lg:w-full lg:text-xl lg:leading-8"
305305
disabled={!isValid}
306306
onClick={handleSubmit(() => mutation.mutate())}
307307
>

โ€Žsrc/app/(pages)/(albaform)/alba/[formId]/edit/page.tsxโ€Ž

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,10 @@ export default function EditFormPage() {
7575
description: albaFormDetailData.description,
7676
title: albaFormDetailData.title,
7777
imageUrls: albaFormDetailData.imageUrls, // ํ”„๋ฆฌ๋ทฐ ๋ฐ˜์˜ํ•˜๊ธฐ
78-
imageFiles: [],
7978
});
8079
}
8180
}, [albaFormDetailData, reset]);
8281

83-
useEffect(() => {
84-
if (albaFormDetailData) {
85-
// console.log("data", data);
86-
console.log("currentValues", currentValues);
87-
}
88-
}, [albaFormDetailData, currentValues]);
89-
9082
// ์ด๋ฏธ์ง€ ์—…๋กœ๋“œ api
9183
const uploadImages = async (files: File[]) => {
9284
if (currentValues.imageUrls.length !== currentValues.imageFiles.length) {
@@ -232,13 +224,13 @@ export default function EditFormPage() {
232224
onChange={handleOptionChange}
233225
currentParam={currentParam || ""}
234226
/>
235-
<div className="absolute -bottom-[120px] mb-5 flex flex-col gap-2 lg:relative lg:bottom-0">
227+
<div className="absolute -bottom-[120px] mb-10 flex w-[320px] lg:relative lg:bottom-0 lg:w-full">
236228
<Button
237229
type="submit"
238230
variant="solid"
239231
width="md"
240232
color="orange"
241-
className="h-[58px] lg:h-[72px] lg:text-xl lg:leading-8"
233+
className="h-[58px] w-full lg:h-[72px] lg:text-xl lg:leading-8"
242234
disabled={!isValid}
243235
onClick={handleSubmit(() => mutation.mutate())}
244236
>

โ€Žsrc/app/(pages)/(albaform)/apply/[formId]/page.tsxโ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,13 @@ export default function Apply() {
220220
errormessage={errors.password?.message}
221221
/>
222222
</div>
223-
<div className="lg:flex-2 mt-4 flex flex-col gap-[10px] lg:mt-8 lg:flex-row">
223+
<div className="lg:flex-2 mt-4 flex w-full flex-col gap-[10px] lg:mt-8 lg:flex-row">
224224
<Button
225225
type="button"
226226
variant="outlined"
227227
width="md"
228228
color="orange"
229-
className="h-[58px] border lg:h-[72px] lg:text-xl lg:leading-8"
229+
className="h-[58px] w-full border lg:h-[72px] lg:text-xl lg:leading-8"
230230
onClick={onTempSave}
231231
disabled={!isDirty}
232232
>
@@ -237,7 +237,7 @@ export default function Apply() {
237237
variant="solid"
238238
width="md"
239239
color="orange"
240-
className="h-[58px] lg:h-[72px] lg:text-xl lg:leading-8"
240+
className="h-[58px] w-full lg:h-[72px] lg:text-xl lg:leading-8"
241241
disabled={!isValid || !isDirty}
242242
>
243243
์ž‘์„ฑ ์™„๋ฃŒ
File renamed without changes.

โ€Žsrc/app/(pages)/(albaform)/component/addFormLayout/AddFormLayout.tsxโ€Ž

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,54 @@
11
"use client";
2-
import AddFormLayout from "@/app/(pages)/(albaform)/component/addFormLayout/AddFormLayout";
32
import { ReactNode, Suspense } from "react";
3+
import { cn } from "@/lib/tailwindUtil";
4+
import ApplyHeader from "./component/ApplyHeader";
5+
import useModalStore from "@/store/modalStore";
6+
import { usePathname, useRouter } from "next/navigation";
47

58
export default function Layout({ children }: { children: ReactNode }) {
9+
const router = useRouter();
10+
const pathname = usePathname();
11+
const title = pathname.split("/").includes("apply") ? "์•Œ๋ฐ”ํผ ์ง€์›ํ•˜๊ธฐ" : "์•Œ๋ฐ”ํผ ๋งŒ๋“ค๊ธฐ";
12+
13+
const { openModal } = useModalStore();
14+
615
return (
7-
<AddFormLayout>
16+
<div
17+
className={cn(
18+
"mx-auto my-10 w-[327px] pb-[70px] lg:w-[680px] lg:pb-0 lg:pl-10",
19+
title === "์•Œ๋ฐ”ํผ ๋งŒ๋“ค๊ธฐ" ? "lg:ml-[600px]" : ""
20+
)}
21+
>
22+
<ApplyHeader
23+
title={title}
24+
onCancel={() =>
25+
openModal("customForm", {
26+
isOpen: true,
27+
title: "ํผ ์ž‘์„ฑ ์ทจ์†Œ",
28+
content: "์ž‘์„ฑ์„ ์ทจ์†Œํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?",
29+
onConfirm: () => {
30+
openModal("customForm", {
31+
isOpen: false,
32+
title: "",
33+
content: "",
34+
onConfirm: () => {},
35+
onCancel: () => {},
36+
});
37+
router.back();
38+
},
39+
onCancel: () => {
40+
openModal("customForm", {
41+
isOpen: false,
42+
title: "",
43+
content: "",
44+
onConfirm: () => {},
45+
onCancel: () => {},
46+
});
47+
},
48+
})
49+
}
50+
/>
851
<Suspense fallback={<div>Loading...</div>}>{children}</Suspense>
9-
</AddFormLayout>
52+
</div>
1053
);
1154
}

โ€Žsrc/app/components/button/dropdown/InputDropdown.tsxโ€Ž

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,29 @@ const InputDropdown = forwardRef<HTMLInputElement, InputDropdownProps>(
1818
const [isOpen, setIsOpen] = useState<boolean>(false);
1919
const [selectedValue, setSelectedValue] = useState<string>("");
2020
const [isCustomInput, setIsCustomInput] = useState<boolean>(false);
21-
const { setValue, getValues } = useFormContext();
21+
const { setValue, watch } = useFormContext();
2222

2323
const handleOptionClick = (option: string) => {
2424
if (option === "์ง์ ‘ ์ž…๋ ฅ") {
2525
setIsCustomInput(true);
2626
setSelectedValue("");
2727
// ๋™์ ์œผ๋กœ ๋ฐ›์•„์˜จ name์— ๊ฐ’ ํ• ๋‹น -> ํ›…ํผ์— ์ €์žฅ
28-
setValue(name, selectedValue);
28+
setValue(name, selectedValue, { shouldDirty: true });
2929
} else {
3030
setSelectedValue(option);
3131
setIsCustomInput(false);
32-
setValue(name, option);
32+
setValue(name, option, { shouldDirty: true });
3333
setIsOpen(false);
3434
}
3535
};
3636

3737
// ์ž‘์„ฑ์ค‘์ธ ํƒญ์œผ๋กœ ๋‹ค์‹œ ์ด๋™ํ–ˆ์„๋•Œ ์ด์ „์— ์ €์žฅ๋œ ํ›…ํผ ๋ฐ์ดํ„ฐ ์—ฐ๋™
3838
useEffect(() => {
39-
const data = getValues();
40-
setSelectedValue(data.name || "");
41-
}, [getValues]);
39+
const value = watch(name); // ๋™์ ์œผ๋กœ ํ•„๋“œ ๊ฐ’ ๊ฐ€์ ธ์˜ค๊ธฐ
40+
if (value !== undefined) {
41+
setSelectedValue(value); // ์ดˆ๊ธฐ๊ฐ’ ๋™๊ธฐํ™”
42+
}
43+
}, [name, watch]);
4244

4345
const textStyle = "text-base";
4446

0 commit comments

Comments
ย (0)