Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
clementprdhomme committed Dec 12, 2024
2 parents af01342 + f1af0b0 commit e9fda10
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 13 deletions.
23 changes: 13 additions & 10 deletions frontend/src/components/map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,19 @@ export const Map: FC<CustomMapProps> = ({
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]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <span className="text-xs">{t('no-data-available')}</span>;
}

const formattedValue = cellFormatter.percentage(locale, value ?? 0);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,41 @@ const HabitatWidget: FCWithMessages<HabitatWidgetProps> = ({ 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 (
<Widget
title={t('proportion-habitat-within-protected-areas')}
lastUpdated={chartData[0]?.updatedAt}
noData={!chartData.length}
loading={isFetching}
info={metadata?.info}
sources={metadata?.sources}
>
{chartData.map((chartData) => (
<HorizontalBarChart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -46,8 +46,7 @@ const TerrestrialWidgets: FCWithMessages = () => {
})}
>
<TerrestrialConservationWidget location={locationData} />
{/* Temporarily hidden due to overestimations caused by the calculation methodology */}
{/* <HabitatWidget location={locationData} /> */}
<HabitatWidget location={locationData} />
</div>
);
};
Expand Down

0 comments on commit e9fda10

Please sign in to comment.