import { regionQueryKeys } from '../regions-query-keys';
import { regionsApi, type PostGetUsersWhoVisitedDataReturn } from '../regions-api';

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

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

export const useGetUsersWhoVisitedDareMutation = () => {
  return useMutation<
    PostGetUsersWhoVisitedDataReturn,
    BaseAxiosError,
    { id: number; page: number; sort?: string; age?: number; country?: string },
    PostGetUsersWhoVisitedDataReturn
  >({
    mutationKey: regionQueryKeys.getUsersWhoVisitedDare(),
    mutationFn: async (variables) => {
      const response = await regionsApi.getUsersWhoVisitedDare(
        variables.id,
        variables.page,
        variables.sort,
        variables.age,
        variables.country
      );
      return response.data;
    }
  });
};
