Skip to content

Commit a7ef50c

Browse files
authored
Merge pull request #114 from FE9-2/feat/albaform/owner
Chore : ์•Œ๋ฐ”ํผ ํŽ˜์ด์ง€ ์ผ๋ถ€ ์ˆ˜์ •
2 parents 4d445a0 + 9178abf commit a7ef50c

File tree

7 files changed

+33
-38
lines changed

7 files changed

+33
-38
lines changed

src/app/(pages)/(albaform)/addform/RecruitCondition.tsx renamed to src/app/(pages)/(albaform)/addform/RecruitConditionSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Label from "../Label";
44
import InputDropdown from "@/app/components/button/dropdown/InputDropdown";
55

66
// ์•Œ๋ฐ”ํผ ๋งŒ๋“ค๊ธฐ - ์‚ฌ์žฅ๋‹˜- 2-๋ชจ์ง‘์กฐ๊ฑด
7-
export default function RecruitCondition() {
7+
export default function RecruitConditionSection() {
88
const {
99
register,
1010
formState: { errors },

src/app/(pages)/(albaform)/addform/RecruitContent.tsx renamed to src/app/(pages)/(albaform)/addform/RecruitContentSection.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ import DatePickerInput from "@/app/components/input/dateTimeDaypicker/DatePicker
77
import { cn } from "@/lib/tailwindUtil";
88
import { useFormContext } from "react-hook-form";
99
import { useEffect, useState } from "react";
10-
import { useSearchParams } from "next/navigation";
1110

1211
// ์•Œ๋ฐ”ํผ ๋งŒ๋“ค๊ธฐ - ์‚ฌ์žฅ๋‹˜ - 1-๋ชจ์ง‘๋‚ด์šฉ
1312

14-
export default function RecruitContent() {
13+
export default function RecruitContentSection() {
1514
// ์ด๋ฏธ์ง€ ํŒŒ์ผ์„ ๋กœ์ปฌ ์ƒํƒœ์— ์ €์žฅ
1615
const [initialImageList, setInitialImageList] = useState<{ file: File; url: string; id: string }[]>([]);
1716

@@ -41,12 +40,9 @@ export default function RecruitContent() {
4140
]);
4241
};
4342

44-
const searchParams = useSearchParams();
45-
const currentParam = searchParams.get("tab");
46-
const initialLoad = currentParam === null; // ์ดˆ๊ธฐ ๋กœ๋”ฉ ์—ฌ๋ถ€ ํ™•์ธ
4743
// ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๋งˆ์šดํŠธ๋  ๋•Œ ์ด๋ฏธ์ง€ ์ดˆ๊ธฐ๊ฐ’ ์„ค์ • (์ดˆ๊ธฐ๋กœ๋”ฉ ์ œ์™ธ)
4844
useEffect(() => {
49-
if (!initialLoad && currentValue.imageFiles?.length > 0) {
45+
if (currentValue.imageFiles?.length > 0) {
5046
handleChangeImages(currentValue.imageFiles);
5147
}
5248
}, []);

src/app/(pages)/(albaform)/addform/WorkCondition.tsx renamed to src/app/(pages)/(albaform)/addform/WorkConditionSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import BaseInput from "@/app/components/input/text/BaseInput";
1212
import CheckBtn from "@/app/components/button/default/CheckBtn";
1313

1414
// ์•Œ๋ฐ”ํผ ๋งŒ๋“ค๊ธฐ - ์‚ฌ์žฅ๋‹˜ - 3-๊ทผ๋ฌด์กฐ๊ฑด
15-
export default function WorkCondition() {
15+
export default function WorkConditionSection() {
1616
const {
1717
register,
1818
setValue,

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

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import { useRouter, useSearchParams } from "next/navigation";
44
import { FormProvider, useForm } from "react-hook-form";
55
import axios from "axios";
66
import TabMenuDropdown from "@/app/components/button/dropdown/TabMenuDropdown";
7-
import RecruitCondition from "./RecruitCondition";
87
import Button from "@/app/components/button/default/Button";
98
import { toast } from "react-hot-toast";
109
import { useMutation } from "@tanstack/react-query";
1110
import { 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

1515
interface 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" },

โ€Žsrc/app/api/forms/[formId]/applications/route.tsโ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ export async function POST(req: NextRequest, { params }: { params: { formId: str
2020
"Content-Type": "application/json",
2121
},
2222
});
23-
23+
console.log(response.data);
2424
return NextResponse.json(response.data);
2525
} catch (error: unknown) {
26+
console.error(error);
2627
if (error instanceof AxiosError) {
2728
console.error(`POST /api/forms/${params.formId}/applications error:`, error);
2829
if (error.response) {

โ€Žsrc/app/components/input/file/ImageInput/ImageInput.tsxโ€Ž

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface ImageInputProps {
1717
}
1818

1919
const ImageInput = forwardRef<HTMLInputElement, ImageInputProps>((props, ref) => {
20-
const [imageList, setImageList] = useState<ImageInputType[]>(props.initialImageList || []); // ๋‹จ์ˆœํžˆ ์ด๋ฏธ์ง€ ํ”„๋ฆฌ๋ทฐ๋ฅผ ์œ„ํ•œ ์ƒํƒœ ๊ด€๋ฆฌ
20+
const [imageList, setImageList] = useState<ImageInputType[]>([]); // ๋‹จ์ˆœํžˆ ์ด๋ฏธ์ง€ ํ”„๋ฆฌ๋ทฐ๋ฅผ ์œ„ํ•œ ์ƒํƒœ ๊ด€๋ฆฌ
2121

2222
const handleFileChange = (selectedFile: File | null) => {
2323
if (selectedFile) {
@@ -42,6 +42,7 @@ const ImageInput = forwardRef<HTMLInputElement, ImageInputProps>((props, ref) =>
4242
props.onChange?.(newImageList.map((img) => img.file).filter((file) => file !== null));
4343
}
4444
};
45+
4546
const handleOpenFileSelecter = () => {
4647
if (typeof ref === "function") {
4748
// input ์š”์†Œ๋ฅผ ์ฐพ์•„์„œ ํด๋ฆญ
@@ -55,6 +56,10 @@ const ImageInput = forwardRef<HTMLInputElement, ImageInputProps>((props, ref) =>
5556
};
5657

5758
const handleDeleteImage = (targetId: string) => {
59+
const targetImage = imageList.find((image) => image.id === targetId);
60+
if (targetImage) {
61+
URL.revokeObjectURL(targetImage.url); // URL ๊ฐ์ฒด ํ•ด์ œ
62+
}
5863
const newImageList = imageList.filter((image) => image.id !== targetId);
5964
setImageList(newImageList);
6065
props.onChange?.(newImageList.map((img) => img.file).filter((file) => file !== null));

โ€Žsrc/app/components/layout/addFormLayout/ApplyHeader.tsxโ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Button from "@/app/components/button/default/Button";
22

33
const ApplyHeader = ({ title, onCancel }: { title: string; onCancel: () => void }) => {
44
return (
5-
<div className="flex w-full items-center justify-between py-5">
5+
<div className="flex w-full items-center justify-between pb-5">
66
<h1 className="text-xl font-semibold leading-5 text-black-500 lg:text-[32px] lg:leading-[46px]">{title}</h1>
77
<Button className="h-10 text-grayscale-50" color="gray" width="xs" onClick={onCancel}>
88
์ž‘์„ฑ ์ทจ์†Œ

0 commit comments

Comments
ย (0)