removed the all location button inthe dispatch page and the rdierlogs page only show the active riders

This commit is contained in:
2026-06-05 09:33:41 +05:30
parent b78730a9a5
commit 174ea5e8f2
2 changed files with 21 additions and 52 deletions

View File

@@ -2788,43 +2788,6 @@ const Dispatch = ({
<div className="logo"> <div className="logo">
<div className="logo-badge">D</div> <div className="logo-badge">D</div>
<div className="logo-name">Dispatch</div> <div className="logo-name">Dispatch</div>
{appLocations && appLocations.length > 0 && (
<div className="logo-city-wrap" ref={locationMenuRef}>
<button
type="button"
className={`logo-city ${locationMenuOpen ? 'open' : ''}`}
onClick={() => setLocationMenuOpen((v) => !v)}
aria-haspopup="listbox"
aria-expanded={locationMenuOpen}
title="Switch hub"
>
<MdPlace />
<span className="logo-city-text">{locationName || 'All locations'}</span>
<MdExpandMore className="logo-city-caret" />
</button>
{locationMenuOpen && (
<div className="logo-city-menu" role="listbox">
{appLocations.map((loc) => {
const isActive = String(loc.applocationid) === String(selectedAppLocationId);
return (
<button
key={loc.applocationid}
type="button"
role="option"
aria-selected={isActive}
className={`logo-city-option ${isActive ? 'active' : ''}`}
onClick={() => handleLocationPick(loc.applocationid)}
>
<MdPlace className="logo-city-option-icon" />
<span>{loc.locationname}</span>
{isActive && <span className="logo-city-option-check"></span>}
</button>
);
})}
</div>
)}
</div>
)}
</div> </div>
{/* Header right-cluster: total-orders pill, date picker. Sits to the {/* Header right-cluster: total-orders pill, date picker. Sits to the

View File

@@ -117,9 +117,16 @@ const RidersLogs = () => {
refetchInterval: 5 * 60 * 1000 refetchInterval: 5 * 60 * 1000
}); });
// Only active riders are surfaced on this page — inactive riders are filtered
// out entirely before they reach the list, selection, counts, or map.
const activeRiders = React.useMemo(
() => (riders || []).filter((r) => r.status === 'active'),
[riders]
);
useEffect(() => { useEffect(() => {
setSelectedRiders(riders); setSelectedRiders(activeRiders);
}, [riders]); }, [activeRiders]);
useEffect(() => { useEffect(() => {
setOpen(isDesktop); setOpen(isDesktop);
@@ -140,10 +147,9 @@ const RidersLogs = () => {
return () => document.removeEventListener('keydown', handleKeyPress); return () => document.removeEventListener('keydown', handleKeyPress);
}, []); }, []);
// Counts shown in the drawer header. // Counts shown in the drawer header (active riders only).
const totalRiders = riders?.length || 0; const totalRiders = activeRiders.length;
const activeCount = (riders || []).filter((r) => r.status === 'active').length; const activeCount = totalRiders;
const inactiveCount = totalRiders - activeCount;
const isAllSelected = totalRiders > 0 && selectedRiders?.length === totalRiders; const isAllSelected = totalRiders > 0 && selectedRiders?.length === totalRiders;
return ( return (
@@ -195,8 +201,11 @@ const RidersLogs = () => {
sx={{ sx={{
position: 'sticky', position: 'sticky',
top: 0, top: 0,
zIndex: 2, zIndex: 5,
background: `linear-gradient(135deg, ${tint(BRAND)} 0%, ${tint(BRAND_LIGHT)} 100%)`, // Solid white base UNDER the translucent brand gradient so the
// scrolling rider list never shows through the sticky header.
backgroundColor: '#fff',
backgroundImage: `linear-gradient(135deg, ${tint(BRAND)} 0%, ${tint(BRAND_LIGHT)} 100%)`,
borderBottom: `1px solid ${DT.borderSubtle}`, borderBottom: `1px solid ${DT.borderSubtle}`,
p: 1.75 p: 1.75
}} }}
@@ -250,9 +259,6 @@ const RidersLogs = () => {
<SoftPill color={C_ACTIVE} icon={<MdCheckCircle size={11} />}> <SoftPill color={C_ACTIVE} icon={<MdCheckCircle size={11} />}>
Active · {activeCount} Active · {activeCount}
</SoftPill> </SoftPill>
<SoftPill color={C_INACTIVE} icon={<MdHighlightOff size={11} />}>
Inactive · {inactiveCount}
</SoftPill>
</Stack> </Stack>
{/* Pill search */} {/* Pill search */}
@@ -301,7 +307,7 @@ const RidersLogs = () => {
<Box <Box
onClick={() => { onClick={() => {
if (!isAllSelected) { if (!isAllSelected) {
setSelectedRiders(riders); setSelectedRiders(activeRiders);
} }
}} }}
sx={{ sx={{
@@ -328,7 +334,7 @@ const RidersLogs = () => {
checked={isAllSelected} checked={isAllSelected}
onChange={(e) => { onChange={(e) => {
if (e.target.checked) { if (e.target.checked) {
setSelectedRiders(riders); setSelectedRiders(activeRiders);
} }
}} }}
sx={{ sx={{
@@ -380,7 +386,7 @@ const RidersLogs = () => {
</Stack> </Stack>
</ListItem> </ListItem>
)) ))
: riders?.map((row) => { : activeRiders.map((row) => {
const isSelected = selectedRiders?.length === 1 && selectedRiders[0]?.userid === row?.userid; const isSelected = selectedRiders?.length === 1 && selectedRiders[0]?.userid === row?.userid;
const statusColor = row.status === 'active' ? C_ACTIVE : C_INACTIVE; const statusColor = row.status === 'active' ? C_ACTIVE : C_INACTIVE;
const initial = (row.firstname || row.username || '?').charAt(0).toUpperCase(); const initial = (row.firstname || row.username || '?').charAt(0).toUpperCase();
@@ -422,7 +428,7 @@ const RidersLogs = () => {
if (e.target.checked) { if (e.target.checked) {
setSelectedRiders([row]); setSelectedRiders([row]);
} else { } else {
setSelectedRiders(riders); setSelectedRiders(activeRiders);
} }
}} }}
sx={{ sx={{