updates on the zone fix
This commit is contained in:
@@ -23,15 +23,11 @@ export function ZoneProvider({ children }) {
|
||||
const tenantId = user?.tenantid || localStorage.getItem('tenantid') || '';
|
||||
const isTenantUser = Boolean(tenantId && tenantId !== '0');
|
||||
|
||||
// A client login's city (from the login response), used to offer them the
|
||||
// Doormile hubs of their own city. Missing on a session signed in before the
|
||||
// backend sent it, in which case every active hub is offered.
|
||||
const clientCityId = user?.applocationid != null && String(user.applocationid) !== '0' ? String(user.applocationid) : '';
|
||||
|
||||
// Staff see Doormile's hubs. A client sees their own locations (kitchens,
|
||||
// depots) AND the Doormile hubs of their city: a newly onboarded client had
|
||||
// no locations at all, so their zone list was just "All Zones" and the
|
||||
// Coimbatore hub their orders run through never appeared.
|
||||
// Staff see Doormile's hubs. A client sees ONLY its own locations (kitchens,
|
||||
// depots). Doormile's hubs used to be appended for the client's city, and
|
||||
// for every city whenever the session carried no city (any login made
|
||||
// before the backend sent one), which is how a Coimbatore client ended up
|
||||
// offered Hyderabad and Bangalore hubs.
|
||||
const { data: rawHubs = [], isLoading: isHubsLoading, refetch: refetchHubs } = useHubs();
|
||||
const { data: tenantLocations = [], isLoading: isLocationsLoading, refetch: refetchLocations } = useTenantLocations(
|
||||
isTenantUser ? tenantId : null,
|
||||
@@ -72,14 +68,11 @@ export function ZoneProvider({ children }) {
|
||||
isTenantLocation: true,
|
||||
status: 'Active',
|
||||
}));
|
||||
const cityHubs = clientCityId
|
||||
? doormileHubs.filter((hub) => String(hub.applocationid ?? '') === clientCityId)
|
||||
: doormileHubs;
|
||||
return [...own, ...cityHubs];
|
||||
return own;
|
||||
}
|
||||
|
||||
return doormileHubs;
|
||||
}, [isTenantUser, tenantLocations, rawHubs, clientCityId]);
|
||||
}, [isTenantUser, tenantLocations, rawHubs]);
|
||||
|
||||
const zones = useMemo(() => {
|
||||
return [ALL_ZONE, ...activeHubs];
|
||||
|
||||
Reference in New Issue
Block a user