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

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

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

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