Skip to content

Commit

Permalink
Merge pull request #235 from Kernel360/page-feature-find-id
Browse files Browse the repository at this point in the history
페이지 기능: 아이디 찾기 기능 추가
  • Loading branch information
bottlewook authored Feb 29, 2024
2 parents 3bdf252 + cb4bf7e commit 6fc6f28
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/app/find-id/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function FindIdPage() {
const { register, handleSubmit, formState: { isValid, errors, isDirty } } = useForm<FindId>({
mode: 'onBlur',
});

const { mutate } = useFindId();

const onSubmit = (data: FindId) => {
Expand Down
2 changes: 1 addition & 1 deletion src/remote/api/requests/auth/auth.post.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const refreshToken = async () => {
export const findId = async ({
email,
}: FindId) => {
const response = await postRequest<ICommon<null>, FindId>('/member/find/memberId', {
const response = await postRequest<ICommon<null>, FindId>('/member/find-memberId', {
email,
});

Expand Down
8 changes: 6 additions & 2 deletions src/remote/queries/auth/useFindId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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('이메일 요청을 실패하였습니다');
},
});
}
Expand Down
12 changes: 7 additions & 5 deletions src/remote/queries/favorite/useFavoriteList.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 () => {
Expand Down

0 comments on commit 6fc6f28

Please sign in to comment.