updates on the ui changes and new changes as well
This commit is contained in:
@@ -15,6 +15,7 @@ import { useZone } from '@/lib/ZoneContext';
|
||||
import { BATCHES, batchRangeLabel, getRowBatchId } from '@/lib/batchBucket';
|
||||
import { formatDoormileTimestamp, parseDoormileTimestamp } from '@/lib/doormileTimestamp';
|
||||
import { currency, exportRows, km as formatKm, matchesQuery, orDash, useDebouncedValue } from '@/lib/doormileFormat';
|
||||
import { toDateRange } from '@/lib/dateRange';
|
||||
import { pickupSourceTypeLabel } from '@/lib/orderFlow';
|
||||
import { summariseRouting } from '@/lib/routingSummary';
|
||||
|
||||
@@ -83,11 +84,7 @@ export default function Deliveries() {
|
||||
const [cancelRow, setCancelRow] = useState(null);
|
||||
const [cancelReason, setCancelReason] = useState('');
|
||||
|
||||
const dateParams = useMemo(() => {
|
||||
if (!selectedDate || selectedDate === 'all') return { from: '', to: '' };
|
||||
if (typeof selectedDate === 'string') return { from: selectedDate, to: selectedDate };
|
||||
return { from: selectedDate.from || '', to: selectedDate.to || '' };
|
||||
}, [selectedDate]);
|
||||
const dateParams = useMemo(() => toDateRange(selectedDate), [selectedDate]);
|
||||
|
||||
const { data, isLoading, isFetching } = useDeliveries({
|
||||
page,
|
||||
@@ -400,11 +397,18 @@ export default function Deliveries() {
|
||||
<DatePicker
|
||||
value={selectedDate}
|
||||
onChange={(d) => {
|
||||
if (d) {
|
||||
const s = dayjs(d).format('YYYY-MM-DD');
|
||||
setDateParams({ from: s, to: s });
|
||||
setSelectedDate(s);
|
||||
}
|
||||
if (!d) return;
|
||||
// Store exactly what the picker emits. It speaks three shapes
|
||||
// — 'YYYY-MM-DD', { from, to } for the range presets, and
|
||||
// 'all' — and `dateParams` below already reads all three.
|
||||
// Forcing every one through dayjs().format() turned both the
|
||||
// range presets and All Dates into the string "Invalid Date".
|
||||
//
|
||||
// The setter that used to be called here first, setDateParams,
|
||||
// does not exist: `dateParams` is derived, not state. The
|
||||
// ReferenceError it threw ran before setSelectedDate, which is
|
||||
// why picking a date did nothing whatsoever.
|
||||
setSelectedDate(d);
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
|
||||
Reference in New Issue
Block a user