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

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

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

export const fetchUserDataDare = () => {
  return useMutation<
    PostGetUserDataDareReturn,
    BaseAxiosError,
    { token: string; dare_id: number },
    PostGetUserDataDareReturn
  >({
    mutationKey: regionQueryKeys.getUserDataDare(),
    mutationFn: async (variables) => {
      const response = await regionsApi.getUserDataDare(variables.dare_id, variables.token);
      return response.data;
    }
  });
};
