import type { PageParams } from '@/lib/api/types';

/**
 * React Query key factory for the addresses domain. Hierarchical keys let every mutation
 * (create/update/delete/set-primary) invalidate all lists with `addressKeys.lists()` — the
 * set-primary flip touches two rows, so we invalidate rather than hand-patch.
 */
export const addressKeys = {
  all: ['addresses'] as const,
  lists: () => [...addressKeys.all, 'list'] as const,
  list: (params?: PageParams) => [...addressKeys.lists(), params ?? {}] as const,
  details: () => [...addressKeys.all, 'detail'] as const,
  detail: (id: number) => [...addressKeys.details(), id] as const,
};
