use-post-login.tsx 541 B

123456789101112131415
  1. import { useQuery } from '@tanstack/react-query';
  2. import { authApi, PostLoginUserReturn } from '../auth-api';
  3. import { BaseAxiosError } from '../../../../types';
  4. import { authQueryKeys } from '../auth-query-keys';
  5. export const usePostLogin = (data: { login: string; pass: string }, enabled: boolean) => {
  6. return useQuery<PostLoginUserReturn, BaseAxiosError>({
  7. queryKey: authQueryKeys.loginUser(),
  8. queryFn: async () => {
  9. const response = await authApi.loginUser(data);
  10. return response.data;
  11. },
  12. enabled
  13. });
  14. };