import type { PageParams } from '@/lib/api/types';
import type { PartnerCenterFilters, SponsoredBookingFilters } from './types';

/**
 * React Query key factory for the partner-center domain. Admin lists key on filters+page; the portal keys
 * are scoped to "my center" (the server resolves the caller's own center — never a raw id). Mutations
 * invalidate the affected sub-tree.
 */
export const centerKeys = {
  all: ['partnerCenter'] as const,

  lists: () => [...centerKeys.all, 'list'] as const,
  list: (filters: PartnerCenterFilters, params: PageParams) => [...centerKeys.lists(), filters, params] as const,

  details: () => [...centerKeys.all, 'detail'] as const,
  detail: (id: number) => [...centerKeys.details(), id] as const,
  sponsoredNurses: (id: number) => [...centerKeys.detail(id), 'sponsoredNurses'] as const,

  // portal (my center)
  myCenter: () => [...centerKeys.all, 'me'] as const,
  mySponsoredNurses: () => [...centerKeys.myCenter(), 'nurses'] as const,
  mySponsoredBookings: (filters: SponsoredBookingFilters, params: PageParams) =>
    [...centerKeys.myCenter(), 'bookings', filters, params] as const,
  mySettlement: (params: PageParams) => [...centerKeys.myCenter(), 'settlement', params] as const,
};
