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: {