{filteredRows.length === 0 && !loading1 && !countSourceLoading && (
No deliveries to show
{selectedBatch === 'all'
? `No ${(STATUS_META[currentStatus]?.label || tabstatus).toLowerCase()} orders for this filter.`
: `No ${(STATUS_META[currentStatus]?.label || tabstatus).toLowerCase()} orders in ${BATCH_OPTIONS.find((b) => b.id === selectedBatch)?.label || 'this batch'}.`}
)}
{filteredRows.length === 0 && countSourceLoading && (
Loading deliveries…
)}
{filteredRows.map((row, index) => {
const rowStatusMeta = STATUS_META[String(row.orderstatus || '').toLowerCase()] || {
label: row.orderstatus || '—',
color: '#94a3b8',
icon: MdHistoryToggleOff
};
const RowStatusIcon = rowStatusMeta.icon;
const isSelected = !!deliverylist.find((res1) => res1.orderheaderid == row.orderheaderid);
const isOpen = productCollapse?.orderid === row?.orderid;
const chipSx = (c) => ({ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', color: c, fontWeight: 700, fontSize: 12, whiteSpace: 'nowrap' });
return (
{showSelect && (
{
if (e.target.checked) {
let arr = deliverylist;
arr.push({ ...row, sno: deliverylist.length + 1 });
setDeliverylist([...arr]);
} else {
let res = deliverylist.find((res1) => res1.orderheaderid == row.orderheaderid);
if (res) {
let arr = deliverylist;
arr.splice(res.sno - 1, 1);
arr.map((val, i) => {
val.sno = i + 1;
});
setDeliverylist([...arr]);
}
}
}}
checked={!!deliverylist.find((res1) => res1.orderheaderid == row.orderheaderid)}
/>
)}
{String(page * rowsPerPage + index + 1).padStart(2, '0')}
{rowStatusMeta.label}
{row.deliverytype == 'C' && (
{
if (productCollapse?.orderid === row.orderid) {
setProductCollapse(null);
setOrderHeaderId(null);
} else {
setProductCollapse(row);
setOrderHeaderId(row.orderheaderid);
}
}}
sx={{ borderRadius: 999, bgcolor: tint('#06b6d4'), color: '#06b6d4', border: `1px solid ${edge('#06b6d4')}`, '&:hover': { bgcolor: soft('#06b6d4') } }}
>
{isOpen ? : }
)}
{showAction && (
handleMenuOpen(e, row)}
sx={{ borderRadius: 999, bgcolor: tint('#662582'), color: '#662582', border: `1px solid ${edge('#662582')}`, '&:hover': { bgcolor: soft('#662582') } }}
>
)}
{row.tenantname}
{[row.tenantsuburb, row.applocation].filter(Boolean).join(' · ') || '—'}
}
>
{`${row.locationname}-(${row.locationsuburb})`}
{row.orderid} · {row.deliveryid}
{row.pickupcustomer || '—'}
{row.pickupcontactno}
{row.deliverycustomer || '—'}
{row.deliverycontactno}
{row.ridername ? (
{row.ridername}
ID #{row.userid} · {row.ridercontact || '—'}
) : (
Unassigned
)}
{row.transitminutes || 0}m
{row.kms || 0} km
{row.cumulativekms || 0} km
₹ {row.deliverycharges?.toFixed(2) ?? '0.00'}
₹ {row.deliveryamt?.toFixed(2) ?? '0.00'}
{row.collectionamt ? `₹ ${row.collectionamt.toFixed(2)}` : '—'}
{row.step ? (
{row.step}
) : (
—
)}
{row.notes && (
{row.notes}
)}
{isOpen && (
Product Details
{orderdetails?.details?.map((product, idx2) => (
{product?.productname || 'Unnamed'}
Qty {product?.orderqty || 0} · ₹ {product?.price || 0}
₹ {(product?.productsumprice + product?.taxamount).toFixed(2) || 0}
))}
Total Amount
₹ {orderdetails?.pricedetails?.orderamount?.toFixed(2)}
)}
);
})}
{countSourceRows?.length != 0 && (
{countIsFetchingNext || countHasNext ? (
) : (
· End of list ·
)}
)}
) : (