updates on the create order design and select location updates
This commit is contained in:
@@ -96,6 +96,25 @@ export default function Deliveries() {
|
||||
const notifyMiler = useNotifyMiler();
|
||||
const { selectedZone, isAllZones, matchesZone } = useZone();
|
||||
|
||||
const riderLookup = useMemo(() => {
|
||||
const map = new Map();
|
||||
(riders || []).forEach((r) => {
|
||||
const name =
|
||||
r.displayname ||
|
||||
[r.firstname, r.lastname].filter(Boolean).join(' ').trim() ||
|
||||
r.name ||
|
||||
r.authname ||
|
||||
(r.label ? r.label.split('|')[0].trim() : '');
|
||||
const phone = r.contactno || r.phone || '';
|
||||
if (r.userid != null) map.set(String(r.userid), { name, phone });
|
||||
if (r.milerid != null) map.set(String(r.milerid), { name, phone });
|
||||
if (r.milerprofileid != null) map.set(String(r.milerprofileid), { name, phone });
|
||||
if (r.id != null) map.set(String(r.id), { name, phone });
|
||||
if (r.value != null) map.set(String(r.value), { name, phone });
|
||||
});
|
||||
return map;
|
||||
}, [riders]);
|
||||
|
||||
const allRows = useMemo(() => {
|
||||
return [...(data?.rows || [])].sort((a, b) => {
|
||||
const ta = parseDoormileTimestamp(a.orderdate || a.assigntime).valueOf() || 0;
|
||||
@@ -138,15 +157,14 @@ export default function Deliveries() {
|
||||
}, [batchRows, unmapped]);
|
||||
|
||||
const rows = useMemo(() => {
|
||||
const scoped =
|
||||
tab === 'all'
|
||||
? batchRows
|
||||
: tab === 'other'
|
||||
? unmapped
|
||||
: batchRows.filter((row) => {
|
||||
const status = String(row.orderstatus || '').toLowerCase();
|
||||
return tab === 'cancelled' ? status === 'cancelled' || status === 'canceled' : status === tab;
|
||||
});
|
||||
let scoped = batchRows;
|
||||
if (tab === 'other') scoped = unmapped;
|
||||
else if (tab !== 'all') {
|
||||
scoped = batchRows.filter((row) => {
|
||||
const status = String(row.orderstatus || '').toLowerCase();
|
||||
return tab === 'cancelled' ? status === 'cancelled' || status === 'canceled' : status === tab;
|
||||
});
|
||||
}
|
||||
|
||||
return scoped.filter((row) =>
|
||||
matchesQuery(
|
||||
@@ -213,12 +231,24 @@ export default function Deliveries() {
|
||||
key: 'ridername',
|
||||
header: 'Rider',
|
||||
sortable: true,
|
||||
cell: (row) => (
|
||||
<div className="min-w-0">
|
||||
<p className="truncate text-body-sm text-ink-1">{orDash(row.ridername)}</p>
|
||||
<p className="text-caption text-ink-3">{orDash(row.ridercontact)}</p>
|
||||
</div>
|
||||
),
|
||||
cell: (row) => {
|
||||
const riderKey = String(row.userid || row.milerprofileid || '');
|
||||
const info = riderLookup.get(riderKey);
|
||||
const name =
|
||||
(info?.name && !info.name.startsWith('Rider #'))
|
||||
? info.name
|
||||
: (row.ridername && !row.ridername.startsWith('Rider #'))
|
||||
? row.ridername
|
||||
: (info?.name || row.ridername || (row.userid ? `Rider #${row.userid}` : '—'));
|
||||
const contact = info?.phone || row.ridercontact;
|
||||
|
||||
return (
|
||||
<div className="min-w-0">
|
||||
<p className="truncate text-body-sm font-semibold text-ink-1">{name}</p>
|
||||
<p className="text-caption text-ink-3">{orDash(contact)}</p>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
hideBelow: 'md',
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user