diff --git a/src/app/find-id/page.tsx b/src/app/find-id/page.tsx index 35bff7ad..1e53b105 100644 --- a/src/app/find-id/page.tsx +++ b/src/app/find-id/page.tsx @@ -23,6 +23,7 @@ function FindIdPage() { const { register, handleSubmit, formState: { isValid, errors, isDirty } } = useForm({ mode: 'onBlur', }); + const { mutate } = useFindId(); const onSubmit = (data: FindId) => { diff --git a/src/remote/api/requests/auth/auth.post.api.ts b/src/remote/api/requests/auth/auth.post.api.ts index d76ceaa3..02fb7104 100644 --- a/src/remote/api/requests/auth/auth.post.api.ts +++ b/src/remote/api/requests/auth/auth.post.api.ts @@ -34,7 +34,7 @@ export const refreshToken = async () => { export const findId = async ({ email, }: FindId) => { - const response = await postRequest, FindId>('/member/find/memberId', { + const response = await postRequest, FindId>('/member/find-memberId', { email, }); diff --git a/src/remote/queries/auth/useFindId.ts b/src/remote/queries/auth/useFindId.ts index 9c4f04af..5ab3945b 100644 --- a/src/remote/queries/auth/useFindId.ts +++ b/src/remote/queries/auth/useFindId.ts @@ -3,7 +3,7 @@ import { toast } from 'react-toastify'; import { useMutation } from '@tanstack/react-query'; import { AxiosError } from 'axios'; -import { useRouter } from 'next/router'; +import { useRouter } from 'next/navigation'; import { findId } from '@remote/api/requests/auth/auth.post.api'; @@ -15,7 +15,11 @@ function useFindId() { router.push('/find-id/complete'); }, onError: (error: AxiosError) => { - toast.error(error.message); + if (error.response?.status === 400) { + toast.error('유효하지 않은 이메일입니다.'); + return; + } + toast.error('이메일 요청을 실패하였습니다'); }, }); } diff --git a/src/remote/queries/favorite/useFavoriteList.ts b/src/remote/queries/favorite/useFavoriteList.ts index 985fd3d3..f9cf7024 100644 --- a/src/remote/queries/favorite/useFavoriteList.ts +++ b/src/remote/queries/favorite/useFavoriteList.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ import { useCallback } from 'react'; import { useInfiniteQuery } from '@tanstack/react-query'; @@ -29,14 +31,14 @@ function useFavoriteList(sortType: SearchFilterType = 'recent-order') { : lastPage.value.pageable.pageNumber + 1 ); }, + onError: (error: any) => { + if (error.response.status === 401) { + router.push('/login'); + } + }, suspense: true, }); - // 유효하지 않는 토큰인 경우 - if (data?.pages[0].status === 401) { - router.push('/login'); - } - const favoriteList = data?.pages.flatMap((page) => { return page.value.content; }) || []; const loadMore = useCallback(async () => {