import { useQuery } from '@tanstack/react-query';
import { authApi, PostLoginUserReturn } from '../auth-api';
import { BaseAxiosError } from '../../../../types';
import { authQueryKeys } from '../auth-query-keys';

export const usePostLogin = (data: { login: string; pass: string }, enabled: boolean) => {
  return useQuery<PostLoginUserReturn, BaseAxiosError>({
    queryKey: authQueryKeys.loginUser(),
    queryFn: async () => {
      const response = await authApi.loginUser(data);
      return response.data;
    },
    enabled
  });
};
