import { useQuery } from '@tanstack/react-query';
import { partnerCenterApi } from '../apis';
import { centerKeys } from '../keys';
import { PARTNER_DETAIL_STALE_TIME, PARTNER_GC_TIME } from '../constants';

/** Admin partner-center detail (IBAN masked last-4). */
export function usePartnerCenter(id: number | null) {
  return useQuery({
    queryKey: centerKeys.detail(id ?? -1),
    queryFn: () => partnerCenterApi.getCenter(id!),
    enabled: id != null && id > 0,
    staleTime: PARTNER_DETAIL_STALE_TIME,
    gcTime: PARTNER_GC_TIME,
  });
}
