From 5a6e6a9451f5dc8300bd8b9ba6cdfaa2298bb19d Mon Sep 17 00:00:00 2001 From: "Adam J. Pain" Date: Mon, 3 Dec 2018 09:41:20 +0100 Subject: [PATCH] Catch no plantations case --- .../pages/dashboards/header/header-actions.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/javascript/pages/dashboards/header/header-actions.js b/app/javascript/pages/dashboards/header/header-actions.js index 8c891c7824..c92d8c6b6b 100644 --- a/app/javascript/pages/dashboards/header/header-actions.js +++ b/app/javascript/pages/dashboards/header/header-actions.js @@ -50,19 +50,23 @@ export const getHeaderData = createThunkAction( // sum over different bound1 within year const summedPlantationsLoss = - latestPlantationLoss.length && latestPlantationLoss[0].area + latestPlantationLoss && + latestPlantationLoss.length && + latestPlantationLoss[0].area ? sumBy(latestPlantationLoss, 'area') : 0; const summedPlantationsEmissions = - latestPlantationLoss.length && latestPlantationLoss[0].emissions + latestPlantationLoss && + latestPlantationLoss.length && + latestPlantationLoss[0].emissions ? sumBy(latestPlantationLoss, 'emissions') : 0; const summedLoss = - latestLoss.length && latestLoss[0].area + latestLoss && latestLoss.length && latestLoss[0].area ? sumBy(latestLoss, 'area') : 0; const summedEmissions = - latestLoss.length && latestLoss[0].emissions + latestLoss && latestLoss.length && latestLoss[0].emissions ? sumBy(latestLoss, 'emissions') : 0;