Skip to content

Commit

Permalink
Merge pull request #132 from Vizzuality/SKY30-185-m-9-the-area-displa…
Browse files Browse the repository at this point in the history
…yed-in-the

[SKY30-185] eez popup: changes total area to protected area
  • Loading branch information
andresgnlez authored Jan 15, 2024
2 parents 2d54de9 + 83df402 commit 7753afb
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions frontend/src/containers/map/content/map/popup/eez/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,17 @@ const EEZLayerPopup = ({ locationId }) => {
return [];
}, [protectionCoverageStats, latestYearAvailable]);

const coveragePercentage = useMemo(() => {
if (latestProtectionCoverageStats.length && locationsQuery.data) {
const totalCumSumProtectedArea = latestProtectionCoverageStats.reduce(
(acc, entry) => acc + entry.attributes.cumSumProtectedArea,
0
);
const totalCumSumProtectedArea = useMemo(() => {
if (!latestProtectionCoverageStats.length) return 0;

return latestProtectionCoverageStats.reduce(
(acc, entry) => acc + entry.attributes.cumSumProtectedArea,
0
);
}, [latestProtectionCoverageStats]);

const coveragePercentage = useMemo(() => {
if (locationsQuery.data) {
const formatter = Intl.NumberFormat('en-US', {
maximumFractionDigits: 0,
});
Expand All @@ -141,7 +145,7 @@ const EEZLayerPopup = ({ locationId }) => {
}

return '-';
}, [latestProtectionCoverageStats, locationsQuery.data]);
}, [totalCumSumProtectedArea, locationsQuery.data]);

// handle renderer
const handleMapRender = useCallback(() => {
Expand Down Expand Up @@ -181,7 +185,7 @@ const EEZLayerPopup = ({ locationId }) => {
<span>
{Intl.NumberFormat('en-US', {
notation: 'standard',
}).format(locationsQuery.data.totalMarineArea)}
}).format(totalCumSumProtectedArea)}
</span>
<span>
km<sup>2</sup>
Expand Down

0 comments on commit 7753afb

Please sign in to comment.