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

/**
 * The signed-in center admin's **own** center (portal scope; server-resolved — never a raw id). Also the
 * de-facto access gate for the `/partner` shell: a resolved center means in-scope; a 403/404 means the
 * caller has no center (access-denied state).
 */
export function useMyPartnerCenter() {
  return useQuery({
    queryKey: centerKeys.myCenter(),
    queryFn: () => partnerCenterApi.getMyCenter(),
    staleTime: PARTNER_DETAIL_STALE_TIME,
    gcTime: PARTNER_GC_TIME,
    retry: false,
  });
}
