Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ft/climatemapped-build-fix #988

Merged
merged 9 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 1 addition & 4 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;
koechkevin marked this conversation as resolved.
Show resolved Hide resolved
const { slug: explorePageSlug } = profilePage;
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
Loading