This commit is contained in:
2026-09-17 11:03:57 +05:30
parent f25b3fcf65
commit 2cd048e6f0
3 changed files with 133 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ import { customersApi, type CustomerQuery } from '@/api/customers';
import { telemetryApi, type RiderSnapshot } from '@/api/telemetry';
import { uploadsApi } from '@/api/uploads';
import { APP_BROWSE_CATEGORY } from '@/features/catalogue/tenantCategories';
import { dedupePartners } from '@/features/nearle-admin/partnerList';
import { queryKeys } from './keys';
import { LIVE_REFETCH_MS } from './interval';
@@ -144,8 +145,12 @@ export function useImportedRefs(tenantid: number | undefined) {
* Every delivery partner across every region.
*
* `getpartners` takes one region at a time and refuses 0, so the whole list is
* the regions fanned out and flattened. Three regions today — Coimbatore,
* the regions fanned out and joined up. Three regions today — Coimbatore,
* Madurai, Nagercoil — so this is three requests, not a page of them.
*
* Joined up, not concatenated: the backend scopes on `partnerlocations`, so a
* partner covering two cities is returned by both of those requests and is
* still one partner. See `dedupePartners`.
*/
export function useAllPartners() {
const regions = useAppRegions();
@@ -159,8 +164,10 @@ export function useAllPartners() {
})),
});
// Deduped, because the per-region answers legitimately overlap now that the
// backend scopes on `partnerlocations` — see `dedupePartners`.
return {
data: results.flatMap((result) => result.data ?? []),
data: dedupePartners(results.map((result) => result.data)),
isLoading: regions.isLoading || results.some((result) => result.isLoading),
};
}