import { useMutation, useQueryClient } from '@tanstack/react-query';
import { adminApi } from '../apis';
import { adminKeys } from '../keys';

/** Resolve an alert with a note (→ resolved). Invalidate the alert worklist on success. */
export function useResolveSupportAlert() {
  const queryClient = useQueryClient();
  return useMutation<void, unknown, { alertId: number; note: string }>({
    mutationFn: ({ alertId, note }) => adminApi.resolveSupportAlert(alertId, note),
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: adminKeys.supportAlerts() });
    },
  });
}
