From 3b4dcd3ffd375134b963b4a8524eada555f0ac6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=82=98=EC=97=B0?= Date: Wed, 16 Oct 2024 16:46:51 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=8B=9C=EA=B0=84=ED=91=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EC=A4=91=EB=B3=B5=20=ED=86=A0=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AddScheduleForm/AddScheduleForm.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/organisms/AddScheduleForm/AddScheduleForm.tsx b/src/components/organisms/AddScheduleForm/AddScheduleForm.tsx index 8117164..7e6463c 100644 --- a/src/components/organisms/AddScheduleForm/AddScheduleForm.tsx +++ b/src/components/organisms/AddScheduleForm/AddScheduleForm.tsx @@ -103,12 +103,18 @@ const AddScheduleForm = ({ onClose }: IProps) => { const postMutation = useMutation({ mutationFn: (data: IScheduleElementDTO) => addScheduleElement(data, userInfo.userName), - onSuccess: () => { - addAlert('강의 추가에 성공했습니다.', 'success'); - onClose(); - queryClient.invalidateQueries({ - queryKey: ['schedule', userInfo.userName], - }); + onSuccess: (res) => { + if (res.success) { + addAlert('강의 추가에 성공했습니다.', 'success'); + onClose(); + queryClient.invalidateQueries({ + queryKey: ['schedule', userInfo.userName], + }); + } else { + if (res.msg === 'Duplicate ScheduleElement Name') { + addAlert('같은 이름의 강의가 존재합니다.', 'error'); + } + } }, onError: () => { addAlert('강의 추가를 실패했습니다.', 'error');