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

import { regionsQueryKeys } from '../regions-query-keys';
import { type PostDeleteVisit, type PostGetSingleRegionReturn, regionsApi } from '../regions-api';

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

export const usePostGetSingleRegionMutation = () => {
  return useMutation<
    PostGetSingleRegionReturn,
    BaseAxiosError,
    PostDeleteVisit,
    PostGetSingleRegionReturn
  >({
    mutationKey: regionsQueryKeys.getSingleRegion(),
    mutationFn: async (data) => {
      const response = await regionsApi.getSingleRegion(data);
      return response.data;
    }
  });
};
