Skip to content

Commit 19ad73b

Browse files
committed
fix: mutateAsync를 mutate로 정리
1 parent 345df9d commit 19ad73b

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

apps/host/src/pages/event-edit/event-edit.tsx

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { NAV_PATH } from '@shared/constants/path';
1919
interface ConfirmModalProps {
2020
title: string;
2121
description?: string;
22-
onConfirm: () => Promise<boolean>;
22+
values: EventFormSubmitValues;
2323
}
2424

2525
interface EventEditPageContentProps {
@@ -60,28 +60,19 @@ const EventEditPageContent = ({ festivalId }: EventEditPageContentProps) => {
6060

6161
const initialValues = toEventEditInitialValues(data);
6262

63-
const submitEdit = async (values: EventFormSubmitValues) => {
64-
const formData = serializeUpdateFestivalFormData(values);
65-
66-
try {
67-
await updateMutation.mutateAsync(formData);
68-
navigate(NAV_PATH.noticeList(festivalId));
69-
return true;
70-
} catch {
71-
toast.show('공연 수정에 실패했어요. 다시 시도해주세요.');
72-
return false;
73-
}
74-
};
75-
7663
const openConfirmModal = ({
7764
title,
7865
description,
79-
onConfirm,
66+
values,
8067
}: ConfirmModalProps) => {
8168
overlay.open(({ isOpen, close, unmount }) => (
8269
<Modal
8370
open={isOpen}
8471
onClose={() => {
72+
if (updateMutation.isPending) {
73+
return;
74+
}
75+
8576
close();
8677
unmount();
8778
}}
@@ -108,13 +99,22 @@ const EventEditPageContent = ({ festivalId }: EventEditPageContentProps) => {
10899
<RectButton
109100
variant='primary'
110101
disabled={updateMutation.isPending}
111-
onClick={async () => {
112-
const isSuccess = await onConfirm();
113-
114-
if (isSuccess) {
115-
close();
116-
unmount();
117-
}
102+
onClick={() => {
103+
const formData = serializeUpdateFestivalFormData(values);
104+
105+
updateMutation.mutate(formData, {
106+
onSuccess: () => {
107+
close();
108+
unmount();
109+
navigate(NAV_PATH.noticeList(festivalId));
110+
},
111+
onError: () => {
112+
toast.show(
113+
'공연 수정에 실패했어요.',
114+
'잠시 후 다시 시도해 주세요.',
115+
);
116+
},
117+
});
118118
}}
119119
>
120120
확인
@@ -147,7 +147,7 @@ const EventEditPageContent = ({ festivalId }: EventEditPageContentProps) => {
147147
description: isCategoryChanged
148148
? '카테고리를 수정하면\n해당 카테고리로 작성된 공지가 삭제돼요.'
149149
: undefined,
150-
onConfirm: () => submitEdit(values),
150+
values,
151151
});
152152
}}
153153
/>

0 commit comments

Comments
 (0)