updates on the minor changes like zone updates and datepicker fix
This commit is contained in:
@@ -124,7 +124,16 @@ export function ZoneProvider({ children }) {
|
||||
if (isTenantUser) {
|
||||
return true;
|
||||
}
|
||||
if (item.applocationid != null && (String(item.applocationid) === targetHubId || String(item.applocationid) === String(currentHub.applocationid))) {
|
||||
// A rider's applocationid is a CITY id; the selected zone is a HUB. Only
|
||||
// compare city with city. This used to also test applocationid against
|
||||
// the hub id — two unrelated number spaces — so with "Coimbatore
|
||||
// Neptune Hub" (hubid 2) selected, every Hyderabad rider (city 2)
|
||||
// matched and the miler lists showed riders from another city.
|
||||
if (
|
||||
item.applocationid != null &&
|
||||
currentHub.applocationid != null &&
|
||||
String(item.applocationid) === String(currentHub.applocationid)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
if (item.hubid != null && String(item.hubid) === targetHubId) {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
/**
|
||||
* The DatePicker's value, as a `{ from, to }` range.
|
||||
*
|
||||
@@ -49,3 +51,23 @@ export const filterByCreatedAt = (rows, value, parse) => {
|
||||
return true;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* DatePicker value → the { from, to } range the report pages query with.
|
||||
*
|
||||
* The shared DatePicker hands back one day ('YYYY-MM-DD') or a { from, to }
|
||||
* range (its presets, or rangeSelect). Reports always need a range, never
|
||||
* past today — they count orders by when they were CREATED, so a future day is
|
||||
* empty by definition — and never inverted.
|
||||
*/
|
||||
export const toReportRange = (value) => {
|
||||
const today = dayjs().format('YYYY-MM-DD');
|
||||
const clamp = (d) => (d && d > today ? today : d);
|
||||
if (typeof value === 'string' && value !== 'all') return { from: clamp(value), to: clamp(value) };
|
||||
if (value && typeof value === 'object') {
|
||||
const from = clamp(value.from || value.to || today);
|
||||
const to = clamp(value.to || value.from || today);
|
||||
return from <= to ? { from, to } : { from: to, to: from };
|
||||
}
|
||||
return { from: today, to: today };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user