partner
This commit is contained in:
@@ -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),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user