import { AuthActionResponse, useAuth } from "@/lib/hooks";
import { ILogin_DTO } from "@shared/contexts";
import { UseMutationOptions, useMutation } from "@tanstack/react-query";

import { useQueryKey } from "../useQueryKey";

export const useLogin = (params?: UseMutationOptions<AuthActionResponse, Error, ILogin_DTO>) => {
  const keys = useQueryKey();
  const { login } = useAuth();

  return useMutation({
    mutationKey: keys().auth().action("login").get(),
    mutationFn: login,
    ...params,
  });
};
