From b0728d37cd74ccfa012d64bb507990ee839285ec Mon Sep 17 00:00:00 2001 From: thisishwarang <101498590+thisishwarang@users.noreply.github.com> Date: Sat, 28 Sep 2024 14:04:40 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EA=B0=9C?= =?UTF-8?q?=EC=84=A4=20=ED=9B=84=20=EC=A1=B0=ED=83=80=EC=9D=B4=20=EC=B4=88?= =?UTF-8?q?=EA=B8=B0=ED=99=94=20(#334)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../class/components/StepThree/StepThree.tsx | 3 +- .../class/hooks/useClassPostInputChange.ts | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/pages/class/components/StepThree/StepThree.tsx b/src/pages/class/components/StepThree/StepThree.tsx index e67bcc7d..105d8e47 100644 --- a/src/pages/class/components/StepThree/StepThree.tsx +++ b/src/pages/class/components/StepThree/StepThree.tsx @@ -27,7 +27,7 @@ import { import { ErrorType } from '@types'; const StepThree = ({ onNext }: StepProps) => { - const { classPostState, handleInputChange } = useClassPostInputChange(); + const { classPostState, handleInputChange, resetClassPostState } = useClassPostInputChange(); const [, setMoimId] = useAtom(moimIdAtom); const { validateStepThree } = useClassPostInputValidation(); const { isTitleValid, isDescriptionValid } = validateStepThree(classPostState); @@ -58,6 +58,7 @@ const StepThree = ({ onNext }: StepProps) => { setMoimId(data); } onNext(); + resetClassPostState(); smoothScroll(0); }) .catch((error: ErrorType) => { diff --git a/src/pages/class/hooks/useClassPostInputChange.ts b/src/pages/class/hooks/useClassPostInputChange.ts index 48eeb45a..6091a27b 100644 --- a/src/pages/class/hooks/useClassPostInputChange.ts +++ b/src/pages/class/hooks/useClassPostInputChange.ts @@ -95,6 +95,38 @@ const useClassPostInputChange = () => { })); }; + const resetClassPostState = () => { + setClassPostState({ + categoryList: { + category1: '', + category2: '', + category3: '', + }, + isOffline: true, + offlineSpot: '', + onlineSpot: '', + date: '', + dayOfWeek: '', + startTime: '', + endTime: '', + maxGuest: 7, + fee: 0, + accountList: { + holder: '', + bank: '', + accountNumber: '', + }, + questionList: { + question1: '', + question2: '', + question3: '', + }, + title: '', + description: '', + imageList: [], + }); + }; + return { classPostState, handleInputChange, @@ -106,6 +138,7 @@ const useClassPostInputChange = () => { handleAccountChange, handleDateChange, handleQuestionChange, + resetClassPostState, }; };