updates on the zone selector for the specific login
This commit is contained in:
@@ -3,7 +3,7 @@ import { Ban, Bell, Bike, FileSpreadsheet, Package, PackageSearch, Truck } from
|
||||
import {
|
||||
Alert, Button, DataTable, Drawer, EmptyState, Field, IconButton, Input,
|
||||
PageHeader, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Modal,
|
||||
Stack, StatusBadge, Surface, Tabs, Textarea,
|
||||
Stack, StatusBadge, Surface, Tabs, Textarea, ZoneSelector,
|
||||
} from '@/components/ds';
|
||||
import { ListToolbar } from '@/components/doormile/ListToolbar';
|
||||
import {
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
useDeliveryCounts, useNotifyMiler, useRiderOptions, useTenants,
|
||||
useUpdateDeliveryStatus,
|
||||
} from '@/lib/doormileHooks';
|
||||
import { useZone } from '@/lib/ZoneContext';
|
||||
import { BATCHES, batchRangeLabel, getRowBatchId } from '@/lib/batchBucket';
|
||||
import { formatDoormileTimestamp, parseDoormileTimestamp } from '@/lib/doormileTimestamp';
|
||||
import { currency, exportRows, km as formatKm, matchesQuery, orDash, useDebouncedValue } from '@/lib/doormileFormat';
|
||||
@@ -93,6 +94,7 @@ export default function Deliveries() {
|
||||
const updateStatus = useUpdateDeliveryStatus();
|
||||
const cancelDelivery = useCancelDelivery();
|
||||
const notifyMiler = useNotifyMiler();
|
||||
const { selectedZone, isAllZones, matchesZone } = useZone();
|
||||
|
||||
const allRows = useMemo(() => {
|
||||
return [...(data?.rows || [])].sort((a, b) => {
|
||||
@@ -102,20 +104,17 @@ export default function Deliveries() {
|
||||
});
|
||||
}, [data?.rows]);
|
||||
|
||||
/* Batch, client and rider first, then status, then search — the counts under
|
||||
/* Zone, Batch, client and rider first, then status, then search — the counts under
|
||||
the tabs have to describe the slice the operator has chosen, not the whole
|
||||
day, or a tab reads 6 and shows 2.
|
||||
|
||||
There is deliberately no site filter: a delivery row carries its client but
|
||||
no tenant-location id, so the only honest filter at that level would be one
|
||||
that silently matched nothing. */
|
||||
day, or a tab reads 6 and shows 2. */
|
||||
const batchRows = useMemo(
|
||||
() =>
|
||||
allRows
|
||||
.filter(matchesZone)
|
||||
.filter((row) => batch === 'all' || getRowBatchId(row) === batch)
|
||||
.filter((row) => tenantId === ALL || String(row.tenantid) === tenantId)
|
||||
.filter((row) => riderId === ALL || String(row.userid) === riderId),
|
||||
[allRows, batch, tenantId, riderId]
|
||||
[allRows, matchesZone, batch, tenantId, riderId]
|
||||
);
|
||||
|
||||
const unmapped = useMemo(
|
||||
@@ -399,6 +398,7 @@ export default function Deliveries() {
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
<ZoneSelector className="w-full sm:w-auto" />
|
||||
<Select value={batch} onValueChange={setBatch}>
|
||||
<SelectTrigger className="w-full sm:w-52">
|
||||
<SelectValue />
|
||||
|
||||
Reference in New Issue
Block a user