updates on the kalman filter and the dispatch page by time filteration updates
This commit is contained in:
@@ -15,9 +15,6 @@ import {
|
||||
MdWbSunny,
|
||||
MdNightsStay,
|
||||
MdCheck,
|
||||
MdTrendingUp,
|
||||
MdTrendingDown,
|
||||
MdTrendingFlat,
|
||||
MdStorefront,
|
||||
MdLocationOn,
|
||||
MdDirectionsBike,
|
||||
@@ -87,7 +84,6 @@ import {
|
||||
changeRiderAPI,
|
||||
fetchCountAPI,
|
||||
fetchDeliveries,
|
||||
fetchPercentageAPI,
|
||||
fetchRidersList,
|
||||
notifyRider,
|
||||
updateDeliveryAPI,
|
||||
@@ -559,13 +555,9 @@ const Deliveries = () => {
|
||||
/* ============================================= || fetchDeliveries | ============================================= */
|
||||
|
||||
const {
|
||||
data: deliveriesData,
|
||||
isLoading: fetchDeliveriesIsLoading,
|
||||
isError: fetchDeliveriesIsError,
|
||||
error: fetchDeliveriesError,
|
||||
fetchNextPage,
|
||||
hasNextPage,
|
||||
isFetchingNextPage,
|
||||
refetch: fetchDeliveriesRefetch
|
||||
} = useInfiniteQuery({
|
||||
queryKey: [
|
||||
@@ -584,7 +576,6 @@ const Deliveries = () => {
|
||||
queryFn: fetchDeliveries,
|
||||
getNextPageParam: (lastPage) => lastPage.nextPage ?? undefined
|
||||
});
|
||||
const rows = deliveriesData?.pages.flatMap((page) => page.rows) || [];
|
||||
|
||||
// (filteredRows is defined below, after countSourceRows / countSourceLoading
|
||||
// are in scope — they're the single source of truth for both the table and
|
||||
@@ -778,21 +769,6 @@ const Deliveries = () => {
|
||||
|
||||
/* ============================================= || fetchPercentageAPI | ============================================= */
|
||||
|
||||
const {
|
||||
data: percentageData,
|
||||
isLoading: fetchPercentageIsLoading,
|
||||
isError: fetchPercentageIsError,
|
||||
error: fetchPercentageError
|
||||
} = useQuery({
|
||||
queryKey: ['fetchpercentageaPI', appId],
|
||||
queryFn: () => fetchPercentageAPI(appId)
|
||||
});
|
||||
useEffect(() => {
|
||||
if (percentageData) {
|
||||
console.log('percentageData', percentageData);
|
||||
}
|
||||
}, [percentageData]);
|
||||
|
||||
/* ============================================= || fetchcount | ============================================= */
|
||||
|
||||
const {
|
||||
@@ -851,18 +827,16 @@ const Deliveries = () => {
|
||||
});
|
||||
|
||||
const errorMessage = fetchDeliveriesIsError
|
||||
? `Error fetching percentages: ${fetchDeliveriesError?.message}`
|
||||
: fetchPercentageIsError
|
||||
? `Error fetching percentages: ${fetchPercentageError?.message}`
|
||||
: fetchCountIsError
|
||||
? `Error fetching percentages: ${fetchCountError?.message}`
|
||||
: ridersListIsError
|
||||
? `Error fetching percentages: ${ridersListError?.message}`
|
||||
: fetchtenantsIsError
|
||||
? `Error tenant list: ${fetchtenantsError?.message}`
|
||||
: fetchlocationsIsError
|
||||
? `Error location list: ${fetchlocationsError?.message}`
|
||||
: null;
|
||||
? `Error fetching deliveries: ${fetchDeliveriesError?.message}`
|
||||
: fetchCountIsError
|
||||
? `Error fetching count summary: ${fetchCountError?.message}`
|
||||
: ridersListIsError
|
||||
? `Error fetching riders: ${ridersListError?.message}`
|
||||
: fetchtenantsIsError
|
||||
? `Error tenant list: ${fetchtenantsError?.message}`
|
||||
: fetchlocationsIsError
|
||||
? `Error location list: ${fetchlocationsError?.message}`
|
||||
: null;
|
||||
|
||||
if (errorMessage) {
|
||||
console.log('errorMessage', errorMessage);
|
||||
@@ -873,7 +847,6 @@ const Deliveries = () => {
|
||||
return (
|
||||
<>
|
||||
{(fetchCountIsLoading ||
|
||||
fetchPercentageIsLoading ||
|
||||
countSourceIsLoading ||
|
||||
fetchtenantsIsLoading ||
|
||||
fetchlocationsIsLoading ||
|
||||
@@ -891,7 +864,6 @@ const Deliveries = () => {
|
||||
}}
|
||||
open={
|
||||
fetchCountIsLoading ||
|
||||
fetchPercentageIsLoading ||
|
||||
fetchDeliveriesIsLoading ||
|
||||
fetchtenantsIsLoading ||
|
||||
fetchlocationsIsLoading ||
|
||||
@@ -979,16 +951,14 @@ const Deliveries = () => {
|
||||
{/* ============================================= || KPI Cards | ============================================= */}
|
||||
<Grid container spacing={{ xs: 1.25, sm: 1.5, md: 2 }} sx={{ mt: '1px' }}>
|
||||
{[
|
||||
{ ...KPI_META[0], value: percentageData?.uncoveredOrders, percentage: percentageData?.percentage1 },
|
||||
{ ...KPI_META[1], value: percentageData?.assignedOrders, percentage: percentageData?.percentage2 },
|
||||
{ ...KPI_META[2], value: percentageData?.pickedOrders, percentage: percentageData?.percentage3 },
|
||||
{ ...KPI_META[3], value: percentageData?.coveredOrders, percentage: percentageData?.percentage4 }
|
||||
{ ...KPI_META[0], value: countData?.total, percentage: null },
|
||||
{ ...KPI_META[1], value: countData?.uncoveredLength, percentage: countData?.total ? Math.round((countData.uncoveredLength / countData.total) * 100) : 0 },
|
||||
{ ...KPI_META[2], value: countData?.coveredLength, percentage: countData?.total ? Math.round((countData.coveredLength / countData.total) * 100) : 0 },
|
||||
{ ...KPI_META[3], value: countData?.cancelLength, percentage: countData?.total ? Math.round((countData.cancelLength / countData.total) * 100) : 0 }
|
||||
].map((item) => {
|
||||
const Icon = item.icon;
|
||||
const pct = typeof item.percentage === 'number' ? item.percentage : Number(item.percentage);
|
||||
const hasPct = !Number.isNaN(pct) && item.percentage !== undefined && item.percentage !== null;
|
||||
const Trend = !hasPct ? MdTrendingFlat : pct > 0 ? MdTrendingUp : pct < 0 ? MdTrendingDown : MdTrendingFlat;
|
||||
const trendColor = !hasPct || pct === 0 ? DT.textMuted : pct > 0 ? '#10b981' : '#ef4444';
|
||||
return (
|
||||
<Grid item key={item.key} xs={6} sm={6} md={3}>
|
||||
<Paper
|
||||
@@ -1037,7 +1007,7 @@ const Deliveries = () => {
|
||||
>
|
||||
{item.label}
|
||||
</Typography>
|
||||
{fetchPercentageIsLoading ? (
|
||||
{fetchCountIsLoading ? (
|
||||
<Skeleton sx={{ width: 70, height: { xs: 28, md: 36 } }} animation="wave" />
|
||||
) : (
|
||||
<Typography
|
||||
@@ -1061,20 +1031,19 @@ const Deliveries = () => {
|
||||
px: 0.75,
|
||||
py: 0.25,
|
||||
borderRadius: 999,
|
||||
bgcolor: soft(trendColor),
|
||||
color: trendColor,
|
||||
bgcolor: soft(item.color),
|
||||
color: item.color,
|
||||
fontSize: { xs: 10, sm: 11 },
|
||||
fontWeight: 800
|
||||
}}
|
||||
>
|
||||
<Trend size={12} />
|
||||
{Math.abs(pct)}%
|
||||
</Box>
|
||||
<Typography
|
||||
variant="caption"
|
||||
sx={{ color: DT.textMuted, display: { xs: 'none', sm: 'inline' } }}
|
||||
>
|
||||
vs. yesterday
|
||||
of total
|
||||
</Typography>
|
||||
</Stack>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user