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 scoped, read-only booking detail behind a sponsored-bookings-list row (REQ-064) — dates + a status
 * timeline only, no clinical content. `bookingId` is `undefined` while the route param hasn't resolved yet
 * (mirrors the disabled-until-ready pattern used by the nurse payout detail hook).
 */
export function useMySponsoredBookingDetail(bookingId: number | undefined) {
  return useQuery({
    queryKey: centerKeys.mySponsoredBookingDetail(bookingId ?? -1),
    queryFn: () => partnerCenterApi.getMySponsoredBookingDetail(bookingId as number),
    enabled: bookingId != null && Number.isFinite(bookingId),
    staleTime: PARTNER_DETAIL_STALE_TIME,
    gcTime: PARTNER_GC_TIME,
  });
}
