Skip to content

Commit cada6f3

Browse files
committed
📝 reset 함수 재적용
1 parent 2305187 commit cada6f3

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

app/registration/step1/page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
import { StoreRegistrationExitConfirmModal, TextField } from 'components/feature';
44
import { LargeBtn, PrivateRoute, StyledLayout, Typography } from 'components/shared';
55
import { useStep1Form } from 'core/useStep1Form';
6+
import { useEffect } from 'react';
67
import { MODAL_KEY } from 'store/actions/modalStore';
78
import { step1ErrorStore } from 'store/actions/step1Store';
89
import { theme } from 'styles';
910
import style from 'styles/style';
1011

1112
const Step1 = () => {
12-
const { name, email, phoneNumber, changeNormal, changeFormNormal } = step1ErrorStore();
13+
const { name, email, phoneNumber, changeNormal, changeFormNormal, resetStep1 } = step1ErrorStore();
1314
const { modalKey, changeModalKey, customPhoneNum, setCurrentKey, handleOnSubmit, handlePhoneNumber } = useStep1Form();
15+
useEffect(() => {
16+
resetStep1();
17+
}, []);
1418
return (
1519
<>
1620
<form onSubmit={handleOnSubmit}>

app/registration/step2/page.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ const Step2 = () => {
5959
} = useStep2Form();
6060
const { name, notice, basicAddress, addressDetail, instaAccount, callNumber, resetStep2 } = step2ErrorStore();
6161
const { data } = useGetStore(query?.get('storeId'));
62+
useEffect(() => {
63+
if (!data) {
64+
resetStep2();
65+
}
66+
}, []);
6267
useEffect(() => {
6368
if (data) {
6469
setData(data);

app/registration/step3/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@ const Step3 = () => {
3434
modalKey,
3535
changeModalKey,
3636
axiosLoading,
37+
resetStep3,
3738
} = useStep3Form();
3839
const { data } = useGetItems(Number(query?.get('storeId')));
40+
useEffect(() => {
41+
if (!data) resetStep3();
42+
}, []);
3943
useEffect(() => {
4044
if (data) {
4145
setProduct(data);

core/useStep2Form.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const useStep2Form = () => {
2727
const [businessHourValues, setBusinessHourValues] = useState<Array<{ day: string; time: string | null }>>([]);
2828
const [axiosLoading, setAxiosLoading] = useState(false);
2929
const { step2Request, setStep2Request } = step2RequestStore();
30-
const { imgPath, registrationNumber, setInputState, setInitialValue, resetStep2 } = step2ErrorStore();
30+
const { imgPath, registrationNumber, setInputState, setInitialValue } = step2ErrorStore();
3131
const { modalKey, changeModalKey } = useModalStore();
3232
const [storePostcodeInputs, setStorePostcodeInputs] = useState({
3333
address: '', // 기본 주소
@@ -42,7 +42,6 @@ export const useStep2Form = () => {
4242
const [S3ImagePath, setS3ImagePath] = useState(imgPath.value[0] ?? '');
4343
const [selectedBusinessHourBtn, setSelectedBusinessHourBtn] = useState('weekDaysWeekEnd');
4444
const { step1Request } = step1RequestStore();
45-
const { resetStep1 } = step1ErrorStore();
4645
const { uploadToS3 } = useS3Upload();
4746
const setData = (data: Store | null | undefined) => {
4847
if (data && query?.get('storeId') !== null) {
@@ -125,16 +124,13 @@ export const useStep2Form = () => {
125124
changeModalKey(MODAL_KEY.OFF);
126125
setAxiosLoading(true);
127126
await patchManager(step1Request);
128-
resetStep1();
129127
const step2Response = await postStore(step2Request);
130-
resetStep2();
131128
router.replace(`/registration/step3?id=${step2Response.storeId}`);
132129
};
133130
const submitEditInputs = async () => {
134131
changeModalKey(MODAL_KEY.OFF);
135132
setAxiosLoading(true);
136133
await patchStore({ ...step2Request, id: Number(query?.get('storeId')) });
137-
resetStep2();
138134
router.replace(`/mypage/store`);
139135
};
140136
const handleSelectedStoreImageBtn = (e: React.ChangeEvent<HTMLInputElement>) => {

0 commit comments

Comments
 (0)