Spaces:
Running
Running
File size: 586 Bytes
4f9f661 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import { useState, useEffect } from 'react';
import { useMutation } from '@tanstack/react-query';
import { login } from './authApi';
import { LoginRequest } from './types';
export const useAuth = () => {
const loginMutation = useMutation({
mutationFn: (data: LoginRequest) => login(data),
onSuccess: (data) => {
console.log(data)
return data;
},
onError: (error) => {
console.error('Login Error:', error);
},
});
return {
login: loginMutation.mutateAsync,
isLoading: loginMutation.isPending,
error: loginMutation.error,
};
}; |