Skip to content

Commit

Permalink
fix: 클래스 개설 후 조타이 초기화 (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
thisishwarang authored Sep 28, 2024
1 parent 02f5c0e commit b0728d3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/pages/class/components/StepThree/StepThree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -58,6 +58,7 @@ const StepThree = ({ onNext }: StepProps) => {
setMoimId(data);
}
onNext();
resetClassPostState();
smoothScroll(0);
})
.catch((error: ErrorType) => {
Expand Down
33 changes: 33 additions & 0 deletions src/pages/class/hooks/useClassPostInputChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -106,6 +138,7 @@ const useClassPostInputChange = () => {
handleAccountChange,
handleDateChange,
handleQuestionChange,
resetClassPostState,
};
};

Expand Down

0 comments on commit b0728d3

Please sign in to comment.