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

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

import type { BaseAxiosError } from '../../../../types';
import { ResponseType } from '@api/response-type';

export const usePostAddVisitMutation = () => {
  return useMutation<ResponseType, BaseAxiosError, PostAddVisit, ResponseType>({
    mutationKey: regionsQueryKeys.addVisit(),
    mutationFn: async (data) => {
      const response = await regionsApi.addVisit(data);
      return response.data;
    }
  });
};
