api integration on the dispatch page
This commit is contained in:
@@ -32,6 +32,11 @@ import {
|
||||
getCustomerOrders,
|
||||
getRiders,
|
||||
getRiderShifts,
|
||||
getRiderPeriodicLogs,
|
||||
getRiderLogs,
|
||||
getBatchEfficiency,
|
||||
updateDelivery,
|
||||
reassignDeliveries,
|
||||
getTenantLocations,
|
||||
getAllTenants,
|
||||
getTenantCustomers,
|
||||
@@ -65,6 +70,9 @@ export const fiestaKeys = {
|
||||
deliveryInsight: (tenantid: number) => ['fiesta', 'deliveryInsight', tenantid] as const,
|
||||
riders: (params: Record<string, unknown>) => ['fiesta', 'riders', params] as const,
|
||||
riderShifts: (applocationid: number) => ['fiesta', 'riderShifts', applocationid] as const,
|
||||
riderPeriodicLogs: (params: Record<string, unknown>) => ['fiesta', 'riderPeriodicLogs', params] as const,
|
||||
riderLogs: (params: Record<string, unknown>) => ['fiesta', 'riderLogs', params] as const,
|
||||
batchEfficiency: (params: Record<string, unknown>) => ['fiesta', 'batchEfficiency', params] as const,
|
||||
// v2: bumped when test-row filtering was added to getTenantLocations so any
|
||||
// warm cache holding the old unfiltered (duplicated/junk) rows is bypassed.
|
||||
tenantLocations: (tenantid: number) => ['fiesta', 'tenantLocations', 'v2', tenantid] as const,
|
||||
@@ -256,6 +264,76 @@ export function useFiestaRiderShifts(applocationid: number = FIESTA_APPLOCATION_
|
||||
});
|
||||
}
|
||||
|
||||
// ── Dispatch / Telemetry ─────────────────────────────────────────────────────
|
||||
export function useFiestaRiderPeriodicLogs(opts: {
|
||||
userid?: number;
|
||||
riderid?: number;
|
||||
fromdate: string;
|
||||
todate: string;
|
||||
tenantid?: number;
|
||||
applocationid?: number;
|
||||
}) {
|
||||
return useQuery({
|
||||
queryKey: fiestaKeys.riderPeriodicLogs(opts),
|
||||
queryFn: () => getRiderPeriodicLogs(opts),
|
||||
enabled: Boolean(opts.fromdate && opts.todate),
|
||||
});
|
||||
}
|
||||
|
||||
export function useFiestaRiderLogs(opts: {
|
||||
userid?: number;
|
||||
riderid?: number;
|
||||
fromdate: string;
|
||||
todate: string;
|
||||
tenantid?: number;
|
||||
applocationid?: number;
|
||||
pageno?: number;
|
||||
pagesize?: number;
|
||||
}) {
|
||||
return useQuery({
|
||||
queryKey: fiestaKeys.riderLogs(opts),
|
||||
queryFn: () => getRiderLogs(opts),
|
||||
enabled: Boolean(opts.fromdate && opts.todate),
|
||||
});
|
||||
}
|
||||
|
||||
export function useFiestaBatchEfficiency(opts: {
|
||||
partnerid?: number;
|
||||
tenantid: number;
|
||||
fromdate: string;
|
||||
todate: string;
|
||||
}) {
|
||||
return useQuery({
|
||||
queryKey: fiestaKeys.batchEfficiency(opts),
|
||||
queryFn: () => getBatchEfficiency(opts),
|
||||
enabled: Boolean(opts.tenantid && opts.fromdate && opts.todate),
|
||||
});
|
||||
}
|
||||
|
||||
export function useFiestaUpdateDelivery() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (input: { deliveryid: number; updates: Row }) =>
|
||||
updateDelivery(input.deliveryid, input.updates),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: ['fiesta', 'deliveries'] });
|
||||
qc.invalidateQueries({ queryKey: ['fiesta', 'deliverySummary'] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useFiestaReassignDeliveries() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (input: { userid: number; deliveryids: number[] }) =>
|
||||
reassignDeliveries(input),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: ['fiesta', 'deliveries'] });
|
||||
qc.invalidateQueries({ queryKey: ['fiesta', 'deliverySummary'] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// ── Tenants / Customers ─────────────────────────────────────────────────────────
|
||||
export function useFiestaTenantLocations(tenantid: number = FIESTA_TENANT_ID) {
|
||||
return useQuery({
|
||||
|
||||
Reference in New Issue
Block a user