diff --git a/apps/climatemappedafrica/src/components/Hero/Hero.js b/apps/climatemappedafrica/src/components/Hero/Hero.js index 6085bc944..abfd54da8 100644 --- a/apps/climatemappedafrica/src/components/Hero/Hero.js +++ b/apps/climatemappedafrica/src/components/Hero/Hero.js @@ -153,6 +153,7 @@ Hero.propTypes = { featuredLocations: PropTypes.arrayOf(PropTypes.shape({})), properties: PropTypes.shape({}), level: PropTypes.string, + explorePageSlug: PropTypes.string, }; export default Hero; diff --git a/apps/climatemappedafrica/src/components/Hero/Map.js b/apps/climatemappedafrica/src/components/Hero/Map.js index bd8f60512..5a828363f 100644 --- a/apps/climatemappedafrica/src/components/Hero/Map.js +++ b/apps/climatemappedafrica/src/components/Hero/Map.js @@ -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); @@ -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()}`, + ); + } }); } }; diff --git a/apps/climatemappedafrica/src/lib/data/blockify/hero.js b/apps/climatemappedafrica/src/lib/data/blockify/hero.js index 8d6b76ca3..0f4cf6684 100644 --- a/apps/climatemappedafrica/src/lib/data/blockify/hero.js +++ b/apps/climatemappedafrica/src/lib/data/blockify/hero.js @@ -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 = { @@ -37,7 +34,7 @@ export default async function hero(block, _api, _context, { hurumap }) { ...block, boundary, center, - explorePageSlug, + explorePageSlug: profilePage?.slug || null, featuredLocations, level, pinRootGeography,