Initial commit
This commit is contained in:
77
src/queries/keys.ts
Normal file
77
src/queries/keys.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* Query keys.
|
||||
*
|
||||
* Every Fiesta list endpoint requires a scoping id and 400s without one, so the
|
||||
* scoping id is part of the key by construction. That is not a caching nicety:
|
||||
* it is what stops one tenant's cached rows being served to another after a
|
||||
* switch.
|
||||
*/
|
||||
|
||||
export const queryKeys = {
|
||||
tenants: {
|
||||
all: ['tenants'] as const,
|
||||
list: () => [...queryKeys.tenants.all, 'list'] as const,
|
||||
locations: (tenantid: number) =>
|
||||
[...queryKeys.tenants.all, 'locations', tenantid] as const,
|
||||
search: (keyword: string) => [...queryKeys.tenants.all, 'search', keyword] as const,
|
||||
},
|
||||
|
||||
catalogue: {
|
||||
all: ['catalogue'] as const,
|
||||
products: (params: Record<string, unknown>) =>
|
||||
[...queryKeys.catalogue.all, 'products', params] as const,
|
||||
brands: () => [...queryKeys.catalogue.all, 'brands'] as const,
|
||||
importedRefs: (tenantid: number) =>
|
||||
[...queryKeys.catalogue.all, 'imported', tenantid] as const,
|
||||
},
|
||||
|
||||
products: {
|
||||
all: ['products'] as const,
|
||||
byLocation: (tenantid: number, locationid: number, page: number) =>
|
||||
[...queryKeys.products.all, 'location', tenantid, locationid, page] as const,
|
||||
categories: (tenantid: number) =>
|
||||
[...queryKeys.products.all, 'categories', tenantid] as const,
|
||||
subCategories: (tenantid: number, categoryid: number) =>
|
||||
[...queryKeys.products.all, 'subcategories', tenantid, categoryid] as const,
|
||||
count: (tenantid: number) => [...queryKeys.products.all, 'count', tenantid] as const,
|
||||
},
|
||||
|
||||
insights: {
|
||||
all: ['insights'] as const,
|
||||
orders: (tenantid: number) => [...queryKeys.insights.all, 'orders', tenantid] as const,
|
||||
locations: (tenantid: number) =>
|
||||
[...queryKeys.insights.all, 'locations', tenantid] as const,
|
||||
deliveries: (tenantid: number) =>
|
||||
[...queryKeys.insights.all, 'deliveries', tenantid] as const,
|
||||
posSales: (locationid: number) =>
|
||||
[...queryKeys.insights.all, 'pos-sales', locationid] as const,
|
||||
posHealth: (locationid: number) =>
|
||||
[...queryKeys.insights.all, 'pos-health', locationid] as const,
|
||||
posSalesSummary: (locationid: number, range: Record<string, unknown>) =>
|
||||
[...queryKeys.insights.all, 'pos-summary', locationid, range] as const,
|
||||
posBills: (locationid: number, params: Record<string, unknown>) =>
|
||||
[...queryKeys.insights.all, 'pos-bills', locationid, params] as const,
|
||||
orderList: (params: Record<string, unknown>) =>
|
||||
[...queryKeys.insights.all, 'order-list', params] as const,
|
||||
deliveryList: (params: Record<string, unknown>) =>
|
||||
[...queryKeys.insights.all, 'delivery-list', params] as const,
|
||||
},
|
||||
|
||||
people: {
|
||||
all: ['people'] as const,
|
||||
staff: (tenantid: number) => [...queryKeys.people.all, 'staff', tenantid] as const,
|
||||
posUsers: (tenantid: number, locationid: number) =>
|
||||
[...queryKeys.people.all, 'pos-users', tenantid, locationid] as const,
|
||||
posRoles: () => [...queryKeys.people.all, 'pos-roles'] as const,
|
||||
shifts: (tenantid: number, locationid: number) =>
|
||||
[...queryKeys.people.all, 'shifts', tenantid, locationid] as const,
|
||||
},
|
||||
|
||||
stock: {
|
||||
all: ['stock'] as const,
|
||||
requests: (params: Record<string, unknown>) =>
|
||||
[...queryKeys.stock.all, 'requests', params] as const,
|
||||
statement: (tenantid: number, locationid: number, params: Record<string, unknown>) =>
|
||||
[...queryKeys.stock.all, 'statement', tenantid, locationid, params] as const,
|
||||
},
|
||||
} as const;
|
||||
Reference in New Issue
Block a user