From 9d2dde07011b2b2da1741ed262101340a21eefba Mon Sep 17 00:00:00 2001 From: bottlewook Date: Fri, 1 Mar 2024 00:19:07 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=EC=95=84=EC=9D=B4=EB=94=94=20?= =?UTF-8?q?=EC=B0=BE=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=20=EC=A0=9C=EC=9E=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/find-id/page.tsx | 1 + src/remote/api/requests/auth/auth.post.api.ts | 2 +- src/remote/queries/auth/useFindId.ts | 8 ++++++-- 3 files changed, 8 insertions(+), 3 deletions(-) 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('이메일 요청을 실패하였습니다'); }, }); } From cb4bf7e1ed8fb75ee8b1f1d7711df2bb1710a839 Mon Sep 17 00:00:00 2001 From: bottlewook Date: Fri, 1 Mar 2024 00:19:53 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20favorite=20401=20=EB=A6=AC=EB=8B=A4?= =?UTF-8?q?=EC=9D=B4=EB=A0=89=ED=8A=B8=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20#226?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/remote/queries/favorite/useFavoriteList.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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 () => {