This commit is contained in:
2026-09-25 15:21:02 +05:30
parent 72f3bb0961
commit d169d24934
12 changed files with 516 additions and 28 deletions

View File

@@ -757,3 +757,19 @@ export function useRiderLive(userids: readonly number[], isEnabled = true) {
isFetching: results.some((result) => result.isFetching),
};
}
/**
* What is in one order — the line items, and the total Fiesta computed.
*
* Enabled only when a drawer is actually open on an order, because this is a
* request per order and the list behind it can hold hundreds. A delivery row
* carries the same `orderheaderid`, so the same hook serves both kinds of sheet.
*/
export function useOrderItems(orderheaderid: number | undefined) {
return useQuery({
queryKey: queryKeys.insights.orderItems(orderheaderid ?? 0),
queryFn: () => insightsApi.orderItems(orderheaderid as number),
enabled: Boolean(orderheaderid),
...stable,
});
}

View File

@@ -90,6 +90,9 @@ export const queryKeys = {
/** The directory — everyone, working today or not. */
riderRoster: (tenantid: number) =>
[...queryKeys.insights.all, 'rider-roster', tenantid] as const,
/** What is in one order. Keyed by the order, never by the list it came from. */
orderItems: (orderheaderid: number) =>
[...queryKeys.insights.all, 'order-items', orderheaderid] as const,
riderShifts: (applocationid: number) =>
[...queryKeys.insights.all, 'rider-shifts', applocationid] as const,
partners: (applocationid: number) =>