Skip to content

Commit

Permalink
feat: define reset custom hook
Browse files Browse the repository at this point in the history
  • Loading branch information
qwer0114 authored and qwer0114 committed Nov 28, 2024
1 parent a687e45 commit 09b7c7c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/client/src/hooks/auth/useResetAccount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { resetAccount as resetAccountAPI } from '@/api/acoount';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { useToast } from '../ui/useToast';

export function useResetAccount() {
const QUERY_KEY = ['RESET_KEY'];
const queryClient = useQueryClient();
const toast = useToast();
const resetAccount = useMutation({
mutationFn: resetAccountAPI,
mutationKey: [QUERY_KEY],
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['MY_ACCOUNT'] });
toast.success('계좌가 초기화 됐어요');
},
onError: (error) => {
toast.error(error.message);
},
});

return resetAccount;
}

0 comments on commit 09b7c7c

Please sign in to comment.