From ec0be4331ecbb2a68855c34c95d71693861e5df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Prod=27homme?= Date: Tue, 26 Nov 2024 13:17:14 +0100 Subject: [PATCH 1/4] refactor(habitat-widget): Re-enable the habitat widget --- .../panels/details/widgets/terrestrial-widgets.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/frontend/src/containers/map/sidebar/main-panel/panels/details/widgets/terrestrial-widgets.tsx b/frontend/src/containers/map/sidebar/main-panel/panels/details/widgets/terrestrial-widgets.tsx index 3eabeedc..1e8d331e 100644 --- a/frontend/src/containers/map/sidebar/main-panel/panels/details/widgets/terrestrial-widgets.tsx +++ b/frontend/src/containers/map/sidebar/main-panel/panels/details/widgets/terrestrial-widgets.tsx @@ -7,7 +7,7 @@ import { cn } from '@/lib/classnames'; import { FCWithMessages } from '@/types'; import { useGetLocations } from '@/types/generated/location'; -// import HabitatWidget from './habitat'; +import HabitatWidget from './habitat'; import TerrestrialConservationWidget from './terrestrial-conservation'; const TerrestrialWidgets: FCWithMessages = () => { @@ -46,8 +46,7 @@ const TerrestrialWidgets: FCWithMessages = () => { })} > - {/* Temporarily hidden due to overestimations caused by the calculation methodology */} - {/* */} + ); }; From 5c00131a96c81d686b0e0142e0c4829dbdeff7d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Prod=27homme?= Date: Mon, 2 Dec 2024 15:04:28 +0100 Subject: [PATCH 2/4] fix(SKY30-507): Remove crash when collapsing sidebar --- frontend/src/components/map/index.tsx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/map/index.tsx b/frontend/src/components/map/index.tsx index 2eb48172..c935dcec 100644 --- a/frontend/src/components/map/index.tsx +++ b/frontend/src/components/map/index.tsx @@ -54,16 +54,19 @@ export const Map: FC = ({ const handleFitBounds = useCallback(() => { if (mapRef && bounds) { const { bbox, options } = bounds; - // enabling fly mode avoids the map to be interrupted during the bounds transition - setFlying(true); - - mapRef.fitBounds( - [ - [bbox[0], bbox[1]], - [bbox[2], bbox[3]], - ], - options - ); + + if (bbox) { + // enabling fly mode avoids the map to be interrupted during the bounds transition + setFlying(true); + + mapRef.fitBounds( + [ + [bbox[0], bbox[1]], + [bbox[2], bbox[3]], + ], + options + ); + } } }, [bounds, mapRef]); From 0c4d4695607c1db9f7a3ac2c71f9238e75fb3d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Prod=27homme?= Date: Mon, 2 Dec 2024 16:12:40 +0100 Subject: [PATCH 3/4] fix(SKY30-508): Indicate when no data is available for Fully/Highly Protected column --- .../map/content/details/tables/global-regional/hooks.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/src/containers/map/content/details/tables/global-regional/hooks.tsx b/frontend/src/containers/map/content/details/tables/global-regional/hooks.tsx index 06416c2a..08344ab2 100644 --- a/frontend/src/containers/map/content/details/tables/global-regional/hooks.tsx +++ b/frontend/src/containers/map/content/details/tables/global-regional/hooks.tsx @@ -272,6 +272,10 @@ export const useColumns = ( const { location } = row.original; const value = location.mpaa_protection_level_stats.percentage; + if (value === null || value === undefined) { + return {t('no-data-available')}; + } + const formattedValue = cellFormatter.percentage(locale, value ?? 0); return ( From f1af0b09c62d26a5b1c88711e3f215f74ea8a557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Prod=27homme?= Date: Thu, 12 Dec 2024 09:23:59 +0100 Subject: [PATCH 4/4] feat(SKY30-509): Add tooltip to Habitat widget --- .../panels/details/widgets/habitat/index.tsx | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/frontend/src/containers/map/sidebar/main-panel/panels/details/widgets/habitat/index.tsx b/frontend/src/containers/map/sidebar/main-panel/panels/details/widgets/habitat/index.tsx index 5aed116a..9651ed1e 100644 --- a/frontend/src/containers/map/sidebar/main-panel/panels/details/widgets/habitat/index.tsx +++ b/frontend/src/containers/map/sidebar/main-panel/panels/details/widgets/habitat/index.tsx @@ -143,12 +143,41 @@ const HabitatWidget: FCWithMessages = ({ location }) => { } ); + const { data: metadata } = useGetDataInfos( + { + locale, + filters: { + slug: 'habitat-widget', + }, + populate: 'data_sources', + }, + { + query: { + select: ({ data }) => + data[0] + ? { + info: data[0].attributes.content, + sources: data[0].attributes?.data_sources?.data?.map( + ({ id, attributes: { title, url } }) => ({ + id, + title, + url, + }) + ), + } + : undefined, + }, + } + ); + return ( {chartData.map((chartData) => (