muryshev's picture
update
4f9f661
raw
history blame contribute delete
586 Bytes
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,
};
};