import { useMutation } from '@tanstack/react-query';

import { userQueryKeys } from '../user-query-keys';
import { userApi } from '../user-api';
import { ResponseType } from '@api/response-type';

import type { BaseAxiosError } from '../../../../types';

export const usePostAuthenticateMutation = () => {
  return useMutation<
    ResponseType,
    BaseAxiosError,
    {
      token: string;
      profile_id: number;
    },
    ResponseType
  >({
    mutationKey: userQueryKeys.autenticate(),
    mutationFn: async (variables) => {
      const response = await userApi.autenticate(variables.token, variables.profile_id);
      return response.data;
    }
  });
};
