updates on the api integration and the design changes on the whole website
This commit is contained in:
@@ -214,15 +214,17 @@ export default function RidersSummary() {
|
||||
});
|
||||
|
||||
// Client-side filter across rider name + id.
|
||||
// GET /admin/milers/summary confirmed live: { milerprofileid, userid,
|
||||
// displayname, phone, availabilitystatus, rating, assigned, accepted,
|
||||
// rejected, completed, cancelled, delivered, riderkms, ridercharges, ... }
|
||||
// — no firstname/lastname/charges/deliveryamt/totalorders/pending/kms/
|
||||
// cumulativekms field exists at all, which is why this whole page showed
|
||||
// "—" everywhere.
|
||||
const filteredRows = useMemo(() => {
|
||||
if (!rows) return [];
|
||||
if (!debouncedSearch) return rows;
|
||||
const q = debouncedSearch.toLowerCase().trim();
|
||||
return rows.filter((r) =>
|
||||
[`${r.firstname || ''} ${r.lastname || ''}`, String(r.userid)]
|
||||
.filter(Boolean)
|
||||
.some((field) => String(field).toLowerCase().includes(q))
|
||||
);
|
||||
return rows.filter((r) => [r.displayname, String(r.userid)].filter(Boolean).some((field) => String(field).toLowerCase().includes(q)));
|
||||
}, [rows, debouncedSearch]);
|
||||
|
||||
// Aggregate KPIs from the loaded summary.
|
||||
@@ -231,9 +233,9 @@ export default function RidersSummary() {
|
||||
return rows.reduce(
|
||||
(acc, r) => {
|
||||
acc.riders += 1;
|
||||
acc.orders += Number(r.totalorders) || 0;
|
||||
acc.orders += Number(r.assigned) || 0;
|
||||
acc.delivered += Number(r.delivered) || 0;
|
||||
acc.amount += Math.max(Number(r.charges) || 0, Number(r.deliveryamt) || 0);
|
||||
acc.amount += Number(r.ridercharges) || 0;
|
||||
return acc;
|
||||
},
|
||||
{ riders: 0, orders: 0, delivered: 0, amount: 0 }
|
||||
@@ -261,7 +263,7 @@ export default function RidersSummary() {
|
||||
// Total Amount sum (preserved from legacy bottom bar).
|
||||
const total = useMemo(() => {
|
||||
if (!rows) return 0;
|
||||
return rows.reduce((sum, row) => sum + (Number(row.deliveryamt) || 0), 0);
|
||||
return rows.reduce((sum, row) => sum + (Number(row.ridercharges) || 0), 0);
|
||||
}, [rows]);
|
||||
|
||||
const KPI_META = [
|
||||
@@ -435,8 +437,8 @@ export default function RidersSummary() {
|
||||
) : (
|
||||
filteredRows.map((row, index) => {
|
||||
const isOpen = openRow === row.userid;
|
||||
const amount = Math.max(Number(row.charges) || 0, Number(row.deliveryamt) || 0);
|
||||
const riderName = `${row?.firstname || ''} ${row?.lastname || ''}`.trim() || '—';
|
||||
const amount = Number(row.ridercharges) || 0;
|
||||
const riderName = row?.displayname || '—';
|
||||
return (
|
||||
<MobileCard
|
||||
key={row.userid || index}
|
||||
@@ -464,7 +466,7 @@ export default function RidersSummary() {
|
||||
onClick={() => {
|
||||
setSelectedRider({
|
||||
userid: row?.userid,
|
||||
name: `${row?.firstname || ''} ${row?.lastname || ''}`.trim() || `Rider ${row?.userid}`
|
||||
name: row?.displayname || `Rider ${row?.userid}`
|
||||
});
|
||||
setLogDetails(null);
|
||||
setMapOpen(true);
|
||||
@@ -504,13 +506,13 @@ export default function RidersSummary() {
|
||||
>
|
||||
<MobileFieldGrid columns={2}>
|
||||
<MobileField label="Orders">
|
||||
<CountCell value={row.totalorders} color={BRAND} icon={<MdLocalShipping size={11} />} />
|
||||
<CountCell value={row.assigned} color={BRAND} icon={<MdLocalShipping size={11} />} />
|
||||
</MobileField>
|
||||
<MobileField label="Delivered">
|
||||
<CountCell value={row.delivered} color="#10b981" icon={<MdCheckCircle size={11} />} />
|
||||
</MobileField>
|
||||
<MobileField label="Pending">
|
||||
<CountCell value={row.pending} color="#f59e0b" icon={<MdHourglassEmpty size={11} />} />
|
||||
<MobileField label="Accepted">
|
||||
<CountCell value={row.accepted} color="#f59e0b" icon={<MdHourglassEmpty size={11} />} />
|
||||
</MobileField>
|
||||
<MobileField label="Cancelled">
|
||||
<CountCell value={row.cancelled} color="#ef4444" icon={<MdCancel size={11} />} />
|
||||
@@ -519,18 +521,10 @@ export default function RidersSummary() {
|
||||
<MetricPill
|
||||
color="#ef4444"
|
||||
icon={<MdStraighten size={11} />}
|
||||
label={`${Number(row.kms || 0).toFixed(2)} km`}
|
||||
label={`${Number(row.riderkms || 0).toFixed(2)} km`}
|
||||
tooltip="KMS"
|
||||
/>
|
||||
</MobileField>
|
||||
<MobileField label="Actual KMS">
|
||||
<MetricPill
|
||||
color="#10b981"
|
||||
icon={<MdStraighten size={11} />}
|
||||
label={`${Number(row.cumulativekms || 0).toFixed(2)} km`}
|
||||
tooltip="Actual KMS"
|
||||
/>
|
||||
</MobileField>
|
||||
<MobileField label="Amount" full>
|
||||
<MetricPill
|
||||
color={BRAND}
|
||||
@@ -687,7 +681,7 @@ export default function RidersSummary() {
|
||||
<TableCell>#</TableCell>
|
||||
<TableCell>Rider</TableCell>
|
||||
<TableCell align="center">Orders</TableCell>
|
||||
<TableCell align="center">Pending</TableCell>
|
||||
<TableCell align="center">Accepted</TableCell>
|
||||
<TableCell align="center">Cancelled</TableCell>
|
||||
<TableCell align="center">Delivered</TableCell>
|
||||
<TableCell align="center">KMS</TableCell>
|
||||
@@ -717,7 +711,7 @@ export default function RidersSummary() {
|
||||
) : (
|
||||
filteredRows.map((row, index) => {
|
||||
const isOpen = openRow === row.userid;
|
||||
const amount = Math.max(Number(row.charges) || 0, Number(row.deliveryamt) || 0);
|
||||
const amount = Number(row.ridercharges) || 0;
|
||||
return (
|
||||
<React.Fragment key={row.userid || index}>
|
||||
<TableRow
|
||||
@@ -745,7 +739,7 @@ export default function RidersSummary() {
|
||||
</AccentAvatar>
|
||||
<Stack>
|
||||
<Typography variant="subtitle2" sx={{ fontWeight: 700, color: DT.textPrimary, whiteSpace: 'nowrap' }}>
|
||||
{`${row?.firstname || ''} ${row?.lastname || ''}`.trim() || '—'}
|
||||
{row?.displayname || '—'}
|
||||
</Typography>
|
||||
<Typography variant="caption" sx={{ color: DT.textSecondary }}>
|
||||
ID #{row.userid}
|
||||
@@ -755,10 +749,10 @@ export default function RidersSummary() {
|
||||
</TableCell>
|
||||
|
||||
<TableCell align="center">
|
||||
<CountCell value={row.totalorders} color={BRAND} icon={<MdLocalShipping size={11} />} />
|
||||
<CountCell value={row.assigned} color={BRAND} icon={<MdLocalShipping size={11} />} />
|
||||
</TableCell>
|
||||
<TableCell align="center">
|
||||
<CountCell value={row.pending} color="#f59e0b" icon={<MdHourglassEmpty size={11} />} />
|
||||
<CountCell value={row.accepted} color="#f59e0b" icon={<MdHourglassEmpty size={11} />} />
|
||||
</TableCell>
|
||||
<TableCell align="center">
|
||||
<CountCell value={row.cancelled} color="#ef4444" icon={<MdCancel size={11} />} />
|
||||
@@ -768,20 +762,12 @@ export default function RidersSummary() {
|
||||
</TableCell>
|
||||
|
||||
<TableCell align="center">
|
||||
<Stack direction="column" spacing={0.5} alignItems="center">
|
||||
<MetricPill
|
||||
color="#ef4444"
|
||||
icon={<MdStraighten size={11} />}
|
||||
label={`${Number(row.kms || 0).toFixed(2)} km`}
|
||||
tooltip="KMS"
|
||||
/>
|
||||
<MetricPill
|
||||
color="#10b981"
|
||||
icon={<MdStraighten size={11} />}
|
||||
label={`${Number(row.cumulativekms || 0).toFixed(2)} km`}
|
||||
tooltip="Actual KMS"
|
||||
/>
|
||||
</Stack>
|
||||
<MetricPill
|
||||
color="#ef4444"
|
||||
icon={<MdStraighten size={11} />}
|
||||
label={`${Number(row.riderkms || 0).toFixed(2)} km`}
|
||||
tooltip="KMS"
|
||||
/>
|
||||
</TableCell>
|
||||
|
||||
<TableCell align="center">
|
||||
@@ -802,7 +788,7 @@ export default function RidersSummary() {
|
||||
onClick={() => {
|
||||
setSelectedRider({
|
||||
userid: row?.userid,
|
||||
name: `${row?.firstname || ''} ${row?.lastname || ''}`.trim() || `Rider ${row?.userid}`
|
||||
name: row?.displayname || `Rider ${row?.userid}`
|
||||
});
|
||||
setLogDetails(null);
|
||||
setMapOpen(true);
|
||||
@@ -881,7 +867,7 @@ export default function RidersSummary() {
|
||||
variant="caption"
|
||||
sx={{ fontWeight: 800, color: DT.textPrimary, letterSpacing: 0.6, textTransform: 'uppercase' }}
|
||||
>
|
||||
Tenant Breakdown · {`${row?.firstname || ''} ${row?.lastname || ''}`.trim()}
|
||||
Tenant Breakdown · {row?.displayname || ''}
|
||||
</Typography>
|
||||
</Stack>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user