rider creation
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
|
||||
import { useQueries, useQuery, type UseQueryOptions } from '@tanstack/react-query';
|
||||
import { catalogueApi, type CatalogueQuery } from '@/api/catalogue';
|
||||
import { deliveriesApi } from '@/api/deliveries';
|
||||
import { deliveriesApi, ridersApi } from '@/api/deliveries';
|
||||
import { insightsApi, type DateRange, type OrderQuery } from '@/api/insights';
|
||||
import { productsApi } from '@/api/products';
|
||||
import { posUsersApi, staffApi } from '@/api/people';
|
||||
@@ -449,3 +449,39 @@ export function useUploads(tenantid: number | undefined, locationid?: number) {
|
||||
...stable,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The rider directory — everyone, whether or not they are working today.
|
||||
*
|
||||
* `stable`, not `live`, and that is the difference from `useRiders`. This is a
|
||||
* staff list: it changes when somebody is hired or edited, not through the day
|
||||
* as shifts start and end. The on-duty read is the one that has to keep asking.
|
||||
*/
|
||||
export function useRiderRoster(tenantid: number | undefined) {
|
||||
return useQuery({
|
||||
queryKey: queryKeys.insights.riderRoster(tenantid ?? 0),
|
||||
queryFn: () => ridersApi.roster(tenantid as number),
|
||||
enabled: Boolean(tenantid),
|
||||
...stable,
|
||||
});
|
||||
}
|
||||
|
||||
/** Shifts a rider can be put on. Scoped by region; the param is required. */
|
||||
export function useRiderShifts(applocationid: number | undefined) {
|
||||
return useQuery({
|
||||
queryKey: queryKeys.insights.riderShifts(applocationid ?? 0),
|
||||
queryFn: () => ridersApi.shifts(applocationid as number),
|
||||
enabled: Boolean(applocationid),
|
||||
...stable,
|
||||
});
|
||||
}
|
||||
|
||||
/** Delivery partners in a region. */
|
||||
export function usePartners(applocationid: number | undefined) {
|
||||
return useQuery({
|
||||
queryKey: queryKeys.insights.partners(applocationid ?? 0),
|
||||
queryFn: () => ridersApi.partners(applocationid as number),
|
||||
enabled: Boolean(applocationid),
|
||||
...stable,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -73,6 +73,13 @@ export const queryKeys = {
|
||||
/** Keyed on the delivery region, which is what the endpoint filters on. */
|
||||
riders: (applocationid: number) =>
|
||||
[...queryKeys.insights.all, 'riders', applocationid] as const,
|
||||
/** The directory — everyone, working today or not. */
|
||||
riderRoster: (tenantid: number) =>
|
||||
[...queryKeys.insights.all, 'rider-roster', tenantid] as const,
|
||||
riderShifts: (applocationid: number) =>
|
||||
[...queryKeys.insights.all, 'rider-shifts', applocationid] as const,
|
||||
partners: (applocationid: number) =>
|
||||
[...queryKeys.insights.all, 'partners', applocationid] as const,
|
||||
},
|
||||
|
||||
people: {
|
||||
|
||||
Reference in New Issue
Block a user