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

/** Record licensing approval and activate a center. Invalidate list + detail. */
export function useVerifyPartnerCenter(id: number) {
  const queryClient = useQueryClient();
  return useMutation<void, unknown, void>({
    mutationFn: () => partnerCenterApi.verifyCenter(id),
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: centerKeys.lists() });
      queryClient.invalidateQueries({ queryKey: centerKeys.detail(id) });
    },
  });
}
