From 26fbecdf625ce33c0fc99a4d700823ce92f6a1ce Mon Sep 17 00:00:00 2001 From: Darren Boss Date: Thu, 12 Sep 2024 09:40:01 -0700 Subject: [PATCH] PR feedback --- .../features/fba/components/infoPanel/AdvisoryText.tsx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/web/src/features/fba/components/infoPanel/AdvisoryText.tsx b/web/src/features/fba/components/infoPanel/AdvisoryText.tsx index 8e37a7251..862bac3fd 100644 --- a/web/src/features/fba/components/infoPanel/AdvisoryText.tsx +++ b/web/src/features/fba/components/infoPanel/AdvisoryText.tsx @@ -6,7 +6,7 @@ import { useSelector } from 'react-redux' import { selectProvincialSummary } from 'features/fba/slices/provincialSummarySlice' import { selectFireCentreHFIFuelStats } from '@/app/rootReducer' import { AdvisoryStatus } from 'utils/constants' -import { isEmpty, isUndefined } from 'lodash' +import { isEmpty, isNil, isUndefined, take } from 'lodash' import { calculateStatusText } from '@/features/fba/calculateZoneStatus' interface AdvisoryTextProps { @@ -56,10 +56,7 @@ const AdvisoryText = ({ const allZoneUnitFuelStats = fireCentreHFIFuelStats?.[selectedFireCenter.name] const selectedZoneUnitFuelStats = allZoneUnitFuelStats?.[selectedFireZoneUnit.fire_shape_id] ?? [] const sortedFuelStats = [...selectedZoneUnitFuelStats].sort(sortByArea) - let topFuels: FireZoneFuelStats[] = [] - for (let i = 0; i < 3 && i < sortedFuelStats.length; i++) { - topFuels.push(sortedFuelStats[i]) - } + let topFuels = take(sortedFuelStats, 3) setSelectedFireZoneUnitTopFuels(topFuels) }, [fireCentreHFIFuelStats]) @@ -115,8 +112,7 @@ const AdvisoryText = ({ const fireCenterSummary = provincialSummary[selectedFireCenter!.name] const fireZoneUnitInfos = fireCenterSummary?.filter(fc => fc.fire_shape_id === selectedFireZoneUnit?.fire_shape_id) const zoneStatus = calculateStatusText(fireZoneUnitInfos, advisoryThreshold) - const hasCriticalHours = - !isUndefined(minStartTime) && !isUndefined(maxEndTime) && selectFireCentreHFIFuelStats.length > 0 + const hasCriticalHours = !isNil(minStartTime) && !isNil(maxEndTime) && selectFireCentreHFIFuelStats.length > 0 let message = '' if (hasCriticalHours) { message = `There is a fire behaviour ${zoneStatus} in effect for ${selectedFireZoneUnit?.mof_fire_zone_name} between ${minStartTime}:00 and ${maxEndTime}:00 for ${getTopFuelsString()}.`