updates on the dispatch page and redesigned the maximum pages
This commit is contained in:
@@ -131,8 +131,17 @@ const ResponsiveLocationDrawer = () => {
|
||||
queryKey: ['locations', debouncedSearchLocation],
|
||||
queryFn: gettenantlocations
|
||||
});
|
||||
// Auto-pick a sensible default whenever the locations list changes:
|
||||
// • Nothing selected yet → pick the first item.
|
||||
// • Current selection has been filtered out → also pick the first item
|
||||
// (otherwise the orders panel queries a locationid that's no longer
|
||||
// in the visible list, returning nothing and confusing the operator).
|
||||
useEffect(() => {
|
||||
if (!searchLocation) locations?.length > 0 ? setSelectedLocation(locations[0]) : null;
|
||||
if (!Array.isArray(locations) || locations.length === 0) return;
|
||||
const stillVisible =
|
||||
selectedLocation &&
|
||||
locations.some((l) => l.locationid === selectedLocation.locationid);
|
||||
if (!stillVisible) setSelectedLocation(locations[0]);
|
||||
}, [locations]);
|
||||
|
||||
const {
|
||||
@@ -334,7 +343,7 @@ const ResponsiveLocationDrawer = () => {
|
||||
color: 'white' // text color
|
||||
}}
|
||||
>
|
||||
{row.locationname[0].toUpperCase()}
|
||||
{row.locationname?.[0]?.toUpperCase() || '?'}
|
||||
</Avatar>{' '}
|
||||
</ListItemAvatar>
|
||||
<ListItemText primary={row.locationname} secondary={row.suburb} />
|
||||
@@ -535,8 +544,8 @@ const ResponsiveLocationDrawer = () => {
|
||||
<Stack>
|
||||
<Typography variant="caption">{row.pickupcustomer}</Typography>
|
||||
<Typography variant="caption">{row.pickupcontactno}</Typography>
|
||||
<Tooltip title={row.pickupaddress}>
|
||||
<Typography variant="caption">{row.pickupsuburb || row.pickupaddress.slice(0, 20)}</Typography>
|
||||
<Tooltip title={row.pickupaddress || ''}>
|
||||
<Typography variant="caption">{row.pickupsuburb || row.pickupaddress?.slice(0, 20) || '—'}</Typography>
|
||||
</Tooltip>
|
||||
</Stack>
|
||||
</Stack>
|
||||
@@ -549,8 +558,8 @@ const ResponsiveLocationDrawer = () => {
|
||||
<Stack>
|
||||
<Typography variant="caption">{row.deliverycustomer}</Typography>
|
||||
<Typography variant="caption">{row.deliverycontactno}</Typography>
|
||||
<Tooltip title={row.deliveryaddress}>
|
||||
<Typography variant="caption">{row.deliverysuburb || row.deliveryaddress.slice(0, 20)}</Typography>
|
||||
<Tooltip title={row.deliveryaddress || ''}>
|
||||
<Typography variant="caption">{row.deliverysuburb || row.deliveryaddress?.slice(0, 20) || '—'}</Typography>
|
||||
</Tooltip>
|
||||
</Stack>
|
||||
</Stack>
|
||||
|
||||
Reference in New Issue
Block a user