-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from dnd-side-project/feature/create-festival
페스티벌 생성 로직 구현
- Loading branch information
Showing
51 changed files
with
1,092 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import instance from "@/apis/instance"; | ||
import FIESTA_ENDPOINTS from "@/config/apiEndpoints"; | ||
import { CreateFestivalType } from "@/validations/CreateFestivalSchema"; | ||
|
||
import { CreateFestivalResponse } from "./createFestivalType"; | ||
|
||
const ENDPOINT = FIESTA_ENDPOINTS.festivals.base; | ||
|
||
export async function createFestival(payload: CreateFestivalType) { | ||
const { images, ...rest } = payload; | ||
const formData = new FormData(); | ||
|
||
formData.append( | ||
"data", | ||
new Blob([JSON.stringify(rest)], { type: "application/json" }), | ||
); | ||
|
||
images?.forEach((image: File) => { | ||
formData.append("images", image); | ||
}); | ||
|
||
const { data } = await instance.post<CreateFestivalResponse>( | ||
ENDPOINT, | ||
formData, | ||
); | ||
|
||
return data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface CreateFestivalResponse { | ||
festivalId: number; | ||
isPending: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/app/(home)/festivals/new/_components/CreateFestivalButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { FC } from "react"; | ||
|
||
import { BasicButton } from "@/components/core/Button"; | ||
|
||
interface Props { | ||
totalStep: number; | ||
currentStep: number; | ||
onNext: () => void; | ||
disabled?: boolean; | ||
} | ||
|
||
const CreateFestivalButton: FC<Props> = ({ | ||
currentStep, | ||
totalStep, | ||
onNext, | ||
disabled, | ||
}) => { | ||
return ( | ||
<div className="fixed bottom-[8px] w-full max-w-none px-[16px] lg:max-w-[450px]"> | ||
<BasicButton | ||
type={totalStep === currentStep ? "submit" : "button"} | ||
label={currentStep === 1 ? "다음" : "페스티벌 등록하기"} | ||
onClick={onNext} | ||
disabled={disabled} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CreateFestivalButton; |
67 changes: 67 additions & 0 deletions
67
src/app/(home)/festivals/new/_components/CreateFestivalFirstStep.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import React from "react"; | ||
import { Controller, useFormContext } from "react-hook-form"; | ||
|
||
import { DescriptionInput, TextInput } from "@/components/core/Input"; | ||
import ImageUploader from "@/components/imageUploader/ImageUploader"; | ||
import { CREATE_FESTIVAL_SETTING } from "@/config"; | ||
import { CreateFestivalType } from "@/validations/CreateFestivalSchema"; | ||
|
||
const CreateFestivalFirstStep = () => { | ||
const { | ||
control, | ||
formState: { dirtyFields }, | ||
} = useFormContext<CreateFestivalType>(); | ||
|
||
return ( | ||
<section className=" flex w-full flex-col gap-[32px]"> | ||
<Controller | ||
control={control} | ||
name="name" | ||
render={({ field: { onChange, value }, formState: { errors } }) => ( | ||
<TextInput | ||
label="페스티벌 명" | ||
placeholder="페스티벌 명을 입력해주세요." | ||
value={value} | ||
onChange={onChange} | ||
currentLength={value?.length ?? 0} | ||
maxLength={30} | ||
error={errors.name?.message} | ||
/> | ||
)} | ||
/> | ||
|
||
<Controller | ||
control={control} | ||
name="images" | ||
render={({ field: { onChange, value }, formState: { errors } }) => ( | ||
<ImageUploader | ||
label="대표 이미지" | ||
value={value} | ||
onChange={onChange} | ||
accept={CREATE_FESTIVAL_SETTING.ACCEPTED_IMAGE_TYPES.map( | ||
(format) => "." + format, | ||
).join(", ")} | ||
/> | ||
)} | ||
/> | ||
|
||
<Controller | ||
control={control} | ||
name="description" | ||
render={({ field: { onChange, value }, formState: { errors } }) => ( | ||
<DescriptionInput | ||
label="상세설명" | ||
placeholder="페스티벌 설명을 작성해주세요." | ||
value={value} | ||
onChange={onChange} | ||
currentLength={value?.length ?? 0} | ||
maxLength={300} | ||
error={errors.description?.message} | ||
/> | ||
)} | ||
/> | ||
</section> | ||
); | ||
}; | ||
|
||
export default CreateFestivalFirstStep; |
Oops, something went wrong.