Skip to content

Commit

Permalink
Merge pull request #988 from CodeForAfrica/ft/climatemapped-build-fix
Browse files Browse the repository at this point in the history
Ft/climatemapped-build-fix
  • Loading branch information
kelvinkipruto authored Nov 6, 2024
2 parents 008da14 + e03e84a commit d5127f2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions apps/climatemappedafrica/src/components/Hero/Hero.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ Hero.propTypes = {
featuredLocations: PropTypes.arrayOf(PropTypes.shape({})),
properties: PropTypes.shape({}),
level: PropTypes.string,
explorePageSlug: PropTypes.string,
};

export default Hero;
18 changes: 11 additions & 7 deletions apps/climatemappedafrica/src/components/Hero/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ function Map({
});
layer.on("mouseover", () => {
onLayerMouseOver(feature.properties.name.toLowerCase());
layer.setStyle({
fillColor: theme.palette.primary.main,
fillOpacity: 0.5,
});
if (explorePageSlug) {
layer.setStyle({
fillColor: theme.palette.primary.main,
fillOpacity: 0.5,
});
}
});
layer.on("mouseout", () => {
onLayerMouseOver(null);
Expand All @@ -55,9 +57,11 @@ function Map({
});
});
layer.on("click", () => {
router.push(
`/${explorePageSlug}/${feature.properties.code.toLowerCase()}`,
);
if (explorePageSlug) {
router.push(
`/${explorePageSlug}/${feature.properties.code.toLowerCase()}`,
);
}
});
}
};
Expand Down
7 changes: 2 additions & 5 deletions apps/climatemappedafrica/src/lib/data/blockify/hero.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ import {
* This function will be called even when HURUmap is disabled.
* @see @/climatemappedafrica/lib/data/common/index.js
*
* TODO(koech): Handle the case when hurumap?.enabled is undefined/false
* Should we hide the map?
*/
export default async function hero(block, _api, _context, { hurumap }) {
const {
profilePage,
rootGeography: { center, code, hasData: pinRootGeography },
} = hurumap;
const { slug: explorePageSlug } = profilePage;
} = hurumap ?? { rootGeography: {} };
const { geometries } = await fetchProfileGeography(code.toLowerCase());
const { level } = geometries.boundary?.properties ?? {};
const childLevelMaps = {
Expand All @@ -37,7 +34,7 @@ export default async function hero(block, _api, _context, { hurumap }) {
...block,
boundary,
center,
explorePageSlug,
explorePageSlug: profilePage?.slug || null,
featuredLocations,
level,
pinRootGeography,
Expand Down

0 comments on commit d5127f2

Please sign in to comment.