Skip to content

Commit

Permalink
feat: 비빌번호 찾기 토스트 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
bottlewook committed Mar 5, 2024
1 parent fe19b19 commit 781491d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/remote/queries/auth/useFindPassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,25 @@ import { toast } from 'react-toastify';

import { useMutation } from '@tanstack/react-query';
import { AxiosError } from 'axios';
import { useRouter } from 'next/navigation';

import { findPassword } from '@remote/api/requests/auth/auth.post.api';

function useFindPassword() {
const router = useRouter();
const onSuccess = () => {
toast.success('이메일이 전송되었습니다.');
router.push('/login');
};

const onError = (error: AxiosError) => {
if (error.response?.status === 400) {
toast.error('유효하지 않은 아이디입니다.');
} else {
toast.error('서버 에러입니다');
}
};
return useMutation({ mutationFn: findPassword, onError });
return useMutation({ mutationFn: findPassword, onSuccess, onError });
}

export default useFindPassword;

0 comments on commit 781491d

Please sign in to comment.