From bc56889f5782f4eefa07755d07a9c93a83140670 Mon Sep 17 00:00:00 2001 From: Devin Matte Date: Tue, 25 Jun 2024 13:24:38 -0400 Subject: [PATCH] Fix crashing overview (#999) --- common/utils/array.ts | 2 +- modules/service/ServiceGraph.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/utils/array.ts b/common/utils/array.ts index 37e88405..dbda549c 100644 --- a/common/utils/array.ts +++ b/common/utils/array.ts @@ -1,7 +1,7 @@ export const indexByProperty = ( array: T[], property: keyof T -) => { +): Record => { const res: Record = {}; array.forEach((el) => { res[el[property]] = el; diff --git a/modules/service/ServiceGraph.tsx b/modules/service/ServiceGraph.tsx index ca8c0f2a..b096c004 100644 --- a/modules/service/ServiceGraph.tsx +++ b/modules/service/ServiceGraph.tsx @@ -53,9 +53,9 @@ export const ServiceGraph: React.FC = (props: ServiceGraphPro data: allDates.map((date) => { const scheduledToday = scheduledDataByDate[date]; const deliveredToday = deliveredDataByDate[date]; - const anyDeliveredToday = deliveredToday?.miles_covered > 0; + const anyDeliveredToday = deliveredToday && deliveredToday.miles_covered > 0; const value = - scheduledToday.count && anyDeliveredToday ? Math.round(scheduledToday.count) / 2 : 0; + scheduledToday?.count && anyDeliveredToday ? Math.round(scheduledToday?.count) / 2 : 0; return { date, value }; }), style: {