This commit is contained in:
2026-09-11 16:32:50 +05:30
parent 81b7d32672
commit 0a11f7543c
24 changed files with 2036 additions and 798 deletions

View File

@@ -340,14 +340,23 @@ export function useLocationProducts(
/* ── Performance ─────────────────────────────────────────────────────────── */
export function useLocationSummary(tenantid: number | undefined) {
return useQuery({
queryKey: queryKeys.insights.locations(tenantid ?? 0),
queryFn: () => insightsApi.locationSummary(tenantid as number),
enabled: typeof tenantid === 'number' && tenantid > 0,
...live,
});
}
/*
No `useLocationSummary`.
It had four callers — Reports, both Consoles and the platform's store detail —
and every one of them read `revenue` and `totalorders` off its rows. Neither
field is in the response; it carries counts under different names and no money
at all. So every "App revenue" on this console read ₹0 against shops with real
takings, and nothing went red because both fields were optional on a type with
an index signature.
It also ignores `fromdate`/`todate`, so even the counts it does return are
all-time whatever the date picker says.
Per-branch figures now come from the order rows via `branchOrderStats`, which
has both the money and a working date filter. `insightsApi.locationSummary`
stays in the API map, correctly typed, if the counts are ever wanted.
*/
export function useOrderSummary(tenantid: number | undefined) {
return useQuery({
@@ -432,7 +441,11 @@ export function useOrders(query: OrderQuery | undefined) {
return useQuery({
queryKey: queryKeys.insights.orderList((query ?? {}) as unknown as Record<string, unknown>),
queryFn: () => insightsApi.orders(query as OrderQuery),
enabled: Boolean(query?.tenantid),
/* Either scope runs it. `tenantid: 0` is what a partner-scoped read sends
for the unused field (see `scopeQuery`), and gating on the tenant alone
meant the platform board fetched nothing at all — the map came up empty
against a partner whose API rows numbered 376. */
enabled: Boolean(query?.tenantid || query?.partnerid),
...live,
});
}
@@ -461,7 +474,11 @@ export function useDeliveries(query: OrderQuery | undefined) {
return useQuery({
queryKey: queryKeys.insights.deliveryList((query ?? {}) as unknown as Record<string, unknown>),
queryFn: () => insightsApi.deliveries(query as OrderQuery),
enabled: Boolean(query?.tenantid),
/* Either scope runs it. `tenantid: 0` is what a partner-scoped read sends
for the unused field (see `scopeQuery`), and gating on the tenant alone
meant the platform board fetched nothing at all — the map came up empty
against a partner whose API rows numbered 376. */
enabled: Boolean(query?.tenantid || query?.partnerid),
...live,
});
}