import { useMutation } from 'react-query';

import { type AxiosError, type AxiosResponse } from 'axios';

import { invalidateCategorizedHoursApprovalQueries } from '../queries';
import {
  type BulkReviewCategorizedHoursError,
  type BulkReviewCategorizedHoursParams,
  type BulkReviewCategorizedHoursResponse,
  bulkReviewCategorizedHours,
} from '../services';

export const useBulkReviewCategorizedHoursMutation = () =>
  useMutation<
    AxiosResponse<BulkReviewCategorizedHoursResponse>,
    AxiosError<BulkReviewCategorizedHoursError>,
    BulkReviewCategorizedHoursParams
  >({
    mutationFn: bulkReviewCategorizedHours,
    onSuccess: () => {
      invalidateCategorizedHoursApprovalQueries();
    },
  });
