import type { BookingRequestListParams } from './types';

/**
 * React Query key factory for the booking-requests domain (hierarchical, per the `services/{domain}`
 * pattern). The list key carries the role + status filter so the customer inbox and the nurse inbox are
 * distinct cache entries and a nurse accept/reject invalidates exactly the right list.
 */
export const bookingRequestKeys = {
  all: ['bookingRequests'] as const,
  lists: () => [...bookingRequestKeys.all, 'list'] as const,
  list: (params: BookingRequestListParams) =>
    [
      ...bookingRequestKeys.lists(),
      params.role,
      params.status ?? 'all',
      params.page ?? 1,
      params.pageSize ?? 0,
    ] as const,
  /** The nurse incoming-requests inbox (a `list` with `role='nurse'`), factored for readability. */
  nurseInbox: (params: BookingRequestListParams) => bookingRequestKeys.list(params),
  details: () => [...bookingRequestKeys.all, 'detail'] as const,
  detail: (id: number) => [...bookingRequestKeys.details(), id] as const,
};
