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

/** Activate / suspend a center (REQ-032). Invalidate list + detail. */
export function useSetPartnerCenterActive(id: number) {
  const queryClient = useQueryClient();
  return useMutation<void, unknown, boolean>({
    mutationFn: (isActive) => partnerCenterApi.setCenterActive(id, isActive),
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: centerKeys.lists() });
      queryClient.invalidateQueries({ queryKey: centerKeys.detail(id) });
    },
  });
}
