From 11f30ac71a537dfeee610eca02c77fbe44258676 Mon Sep 17 00:00:00 2001 From: Moon Dahyun Date: Thu, 22 Aug 2024 00:56:32 +0900 Subject: [PATCH] =?UTF-8?q?feat/#416=20:=20=EA=B4=80=EB=A6=AC=EC=9E=90=20?= =?UTF-8?q?=EA=B8=80=EB=AA=A8=EC=9E=84=20=EC=A0=95=EB=B3=B4=20400?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/admin/hooks/queries.ts | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/pages/admin/hooks/queries.ts b/src/pages/admin/hooks/queries.ts index e53187a4..a7dc90f6 100644 --- a/src/pages/admin/hooks/queries.ts +++ b/src/pages/admin/hooks/queries.ts @@ -216,7 +216,18 @@ export const usePutAdminGroupInfo = ({ }); }, onError: (err) => { - if (isAxiosError(err)) { + if (isAxiosError(err) && err.response?.status) { + const errorCode = err.response?.data.status; + if (errorCode === 40005) { + alert('요청 값에 빈 값이 존재합니다'); + } else if (errorCode === 40006) { + alert('요청 값이 길이를 초과했습니다'); + } else if (errorCode === 40018) { + alert('사용 불가능한 모임명입니다'); + } else { + console.error(); + } + if (err?.response?.status === 500) { alert('서버내부 오류입니다. '); } else if (err?.response?.status === 401) { @@ -232,22 +243,3 @@ export const usePutAdminGroupInfo = ({ return { mutate, isSuccess, isError }; }; - -//모임 정보 삭제 -export const useDeleteGroup = (groupId: string) => { - const queryClient = useQueryClient(); - const navigate = useNavigate(); - const { mutate, isError, isPending } = useMutation({ - mutationKey: [QUERY_KEY_ADMIN.deleteGroup, groupId], - mutationFn: () => deleteGroup(groupId), - onSuccess: () => { - //key에 대한 정책을 변경해야함, 현재는 key의 unique함은 보장되어있지만 관련성이 적어 key의 역할을 제대로 못하고있음 - queryClient.invalidateQueries({ - queryKey: [QUERY_KEY_GROUPFEED.fetchHeaderGroup], - }); - navigate('/'); - }, - }); - - return { mutate, isError, isPending }; -};