diff --git a/frontend/src/app/add-shows/_components/add-shows-form.tsx b/frontend/src/app/add-shows/_components/add-shows-form.tsx index 8be619f..d05a5a4 100644 --- a/frontend/src/app/add-shows/_components/add-shows-form.tsx +++ b/frontend/src/app/add-shows/_components/add-shows-form.tsx @@ -1,18 +1,18 @@ -/* eslint-disable */ "use client"; import { zodResolver } from "@hookform/resolvers/zod"; +import clsx from "clsx"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { useForm } from "react-hook-form"; + import { ShowType } from "../types"; import { addShowForm } from "../validations/schema"; - import BasicInfo from "./basic-info"; import DateTimeSection from "./date-time-select"; +import FacilitiesSection from "./facilities-section"; import LocationSection from "./location-select"; import TagSection from "./tag-select"; -import FacilitiesSection from "./facilities-section"; export default function AddShowsForm() { const router = useRouter(); @@ -25,7 +25,7 @@ export default function AddShowsForm() { setValue, watch, handleSubmit, - formState: { errors, isDirty, isValid }, + formState: { errors, isValid }, } = useForm({ resolver: zodResolver(addShowForm), mode: "all", @@ -47,29 +47,15 @@ export default function AddShowsForm() { }, }); - // 모든 필수 필드를 감시 - const watchedFields = watch([ - "title", - "description", - "startDate", - "endDate", - "openTimes", - "location", - "publicTag", - ]); - - const isFormComplete = watchedFields.every( - (field) => field && field.length > 0, - ); - const formValues = watch(); + const formValues = watch(); //eslint-disable-line const onSubmit = async (data: ShowType) => { try { setIsLoading(true); - console.log(data); + console.log(data); //eslint-disable-line router.push("/shows"); } catch (error) { - console.error("Error:", error); + console.error("Error:", error); //eslint-disable-line } finally { setIsLoading(false); } @@ -110,12 +96,14 @@ export default function AddShowsForm() { @@ -134,10 +122,10 @@ export default function AddShowsForm() { */} {Object.keys(errors).length > 0 && ( -
+
필수입력 항목을 입력해주세요
- {Object.values(errors).map((error, index) => ( -
{error.message}
+ {Object.entries(errors).map(([fieldName, error]) => ( +
{error.message}
))}
)} diff --git a/frontend/src/app/add-shows/types/index.ts b/frontend/src/app/add-shows/types/index.ts index 30a8906..1b80547 100644 --- a/frontend/src/app/add-shows/types/index.ts +++ b/frontend/src/app/add-shows/types/index.ts @@ -14,14 +14,14 @@ export interface ShowType { longitude: string; // 경도 // 편의시설 정보 - isParkingAvailable: boolean; // 주차 가능 여부 - isFoodAllowed: boolean; // 음식물 반입 가능 여부 - isPetAllowed: boolean; // 반려동물 동반 가능 여부 - isKidsZone: boolean; // 키즈존 유무 - isWifiAvailable: boolean; // 와이파이 사용 가능 여부 + isParkingAvailable?: boolean; // 주차 가능 여부 + isFoodAllowed?: boolean; // 음식물 반입 가능 여부 + isPetAllowed?: boolean; // 반려동물 동반 가능 여부 + isKidsZone?: boolean; // 키즈존 유무 + isWifiAvailable?: boolean; // 와이파이 사용 가능 여부 // 요금 및 태그 - fee: number; // 입장료 + fee?: number; // 입장료 publicTag: string; // 대표 태그 - tags: string[]; // 태그 목록 + tags?: string[]; // 태그 목록 } diff --git a/frontend/src/app/add-shows/validations/schema/index.tsx b/frontend/src/app/add-shows/validations/schema/index.tsx index 50a4aed..28f02bc 100644 --- a/frontend/src/app/add-shows/validations/schema/index.tsx +++ b/frontend/src/app/add-shows/validations/schema/index.tsx @@ -17,21 +17,21 @@ export const addShowForm = z.object({ longitude: z.string().optional().nullable(), - fee: z.number().nonnegative().default(0), + fee: z.number().nonnegative().optional().default(0), publicTag: z.string().min(1, "공개 태그는 필수입니다"), - tags: z.array(z.string()).default([]), + tags: z.array(z.string()).optional().default([]), - isParkingAvailable: z.boolean().default(false), + isParkingAvailable: z.boolean().optional().default(false), - isFoodAllowed: z.boolean().default(false), + isFoodAllowed: z.boolean().optional().default(false), - isPetAllowed: z.boolean().default(false), + isPetAllowed: z.boolean().optional().default(false), - isKidsZone: z.boolean().default(false), + isKidsZone: z.boolean().optional().default(false), - isWifiAvailable: z.boolean().default(false), + isWifiAvailable: z.boolean().optional().default(false), }); export type ShowType = z.infer;