From fc031cf8c2da8032c0ef77e4cf08e49a8b982e5f Mon Sep 17 00:00:00 2001 From: WonBeen Choi Date: Mon, 4 Mar 2024 21:43:10 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20?= =?UTF-8?q?=EC=95=A1=EC=85=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/query/register.ts | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/query/register.ts b/src/query/register.ts index 9415fc9a..b5f442d5 100644 --- a/src/query/register.ts +++ b/src/query/register.ts @@ -6,6 +6,7 @@ import parseRegisterData from 'page/Auth/Signup/utils/parseRegisterData'; import useRegisterInfo from 'store/registerStore'; import useShopRegistrationStore from 'store/shopRegistration'; import useUploadToken from 'store/uploadToken'; +import showToast from 'utils/ts/showToast'; export const useCheckDuplicate = (email:string) => { const { status, refetch, error } = useQuery({ @@ -62,11 +63,6 @@ export const useRegisterUser = (goNext:()=>void) => { goNext(); resetRegisterInfo(); }, - onError: () => { - alert('회원가입 중 에러가 발생했습니다. 처음부터 다시 진행해주세요'); - resetRegisterInfo(); - window.location.reload(); - }, }); return { register }; }; @@ -81,16 +77,19 @@ export const useGetFileUrls = (goNext:()=>void) => { }); const fileMutation = useMutation({ mutationKey: ['getFileUrls'], - mutationFn: () => getFileUrls(formData, uploadToken!), - onSuccess: (data) => { - register.mutate(data.file_urls); - }, - onError: () => { - alert('파일 업로드 중 에러가 발생했습니다. 처음부터 다시 진행해주세요'); - resetRegisterInfo(); - window.location.reload(); - }, - + mutationFn: async () => { + try { + const data = await getFileUrls(formData, uploadToken!); + try { + await register.mutateAsync(data.file_urls); + } + catch (e) { + showToast('error', "회원가입 중 에러가 발생했어요" + e); + } + } catch (e) { + showToast('error', "파일업로드 중 에러가 발생했어요" + e); + } + } }); return fileMutation;