Files
Vector/apps/web/src/lib/queryKeys.ts
T
josh 09d1d96cb4
CI / Lint · Typecheck · Test · Build (push) Successful in 49s
CI / Playwright (smoke) (push) Has been skipped
CI / Build & push images (push) Successful in 1m2s
feat(bins): clickable bin cards with dedicated detail page
Clicking a bin on Locations now navigates to /bins/:id, showing the
bin's site/room/name, created/updated metadata, and a paginated
DataTable of parts currently in the bin. Admins can rename or delete
the bin from the detail page; the BinGrid kebab menu still works
without triggering navigation.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-17 15:17:55 -04:00

104 lines
4.0 KiB
TypeScript

// Hierarchical query keys for TanStack Query. Consumers should import this factory rather than
// hard-coding tuples inline so invalidations can be surgical (e.g. invalidate everything under
// `parts.list()` without touching `parts.detail(id)`).
export const queryKeys = {
auth: {
all: ['auth'] as const,
me: () => [...queryKeys.auth.all, 'me'] as const,
},
parts: {
all: ['parts'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.parts.all, 'list', filters ?? {}] as const,
detail: (id: string) => [...queryKeys.parts.all, 'detail', id] as const,
events: (id: string, filters?: Record<string, unknown>) =>
[...queryKeys.parts.all, 'events', id, filters ?? {}] as const,
},
manufacturers: {
all: ['manufacturers'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.manufacturers.all, 'list', filters ?? {}] as const,
detail: (id: string) => [...queryKeys.manufacturers.all, 'detail', id] as const,
insights: (id: string) => [...queryKeys.manufacturers.all, 'insights', id] as const,
},
sites: {
all: ['sites'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.sites.all, 'list', filters ?? {}] as const,
detail: (id: string) => [...queryKeys.sites.all, 'detail', id] as const,
},
rooms: {
all: ['rooms'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.rooms.all, 'list', filters ?? {}] as const,
},
bins: {
all: ['bins'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.bins.all, 'list', filters ?? {}] as const,
detail: (id: string) => [...queryKeys.bins.all, 'detail', id] as const,
},
users: {
all: ['users'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.users.all, 'list', filters ?? {}] as const,
},
hosts: {
all: ['hosts'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.hosts.all, 'list', filters ?? {}] as const,
detail: (id: string) => [...queryKeys.hosts.all, 'detail', id] as const,
deployedParts: (id: string) => [...queryKeys.hosts.all, 'deployed-parts', id] as const,
timeline: (id: string, filters?: Record<string, unknown>) =>
[...queryKeys.hosts.all, 'timeline', id, filters ?? {}] as const,
},
fms: {
all: ['fms'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.fms.all, 'list', filters ?? {}] as const,
detail: (id: string) => [...queryKeys.fms.all, 'detail', id] as const,
},
repairs: {
all: ['repairs'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.repairs.all, 'list', filters ?? {}] as const,
detail: (id: string) => [...queryKeys.repairs.all, 'detail', id] as const,
},
custody: {
all: ['custody'] as const,
mine: (filters?: Record<string, unknown>) =>
[...queryKeys.custody.all, 'mine', filters ?? {}] as const,
},
partModels: {
all: ['part-models'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.partModels.all, 'list', filters ?? {}] as const,
detail: (id: string) => [...queryKeys.partModels.all, 'detail', id] as const,
insights: (id: string) => [...queryKeys.partModels.all, 'insights', id] as const,
},
tags: {
all: ['tags'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.tags.all, 'list', filters ?? {}] as const,
},
categories: {
all: ['categories'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.categories.all, 'list', filters ?? {}] as const,
},
webhooks: {
all: ['webhooks'] as const,
list: (filters?: Record<string, unknown>) =>
[...queryKeys.webhooks.all, 'list', filters ?? {}] as const,
},
savedViews: {
all: ['savedViews'] as const,
list: (resource: string) => [...queryKeys.savedViews.all, resource] as const,
},
analytics: {
all: ['analytics'] as const,
dashboard: () => [...queryKeys.analytics.all, 'dashboard'] as const,
},
} as const;