// [REQ T2]  Custom hooks – useDeleteReservation enkapsuluje useMutation DELETE
// [REQ D7]  React Query – useMutation z invalidateQueries po sukcesie
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { deleteReservation } from '../api/reservations';

export const useDeleteReservation = ({ onSuccess, onError } = {}) => {
  const queryClient = useQueryClient();

  return useMutation({
    mutationFn: deleteReservation,
    onSuccess: (data) => {
      queryClient.invalidateQueries({ queryKey: ['reservations'] });
      onSuccess?.(data);
    },
    onError,
  });
};
