From 40eb7abd01ef4b8eb95c5b60e0dd01cf7af9a56f Mon Sep 17 00:00:00 2001 From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> Date: Mon, 28 Oct 2024 12:17:38 +0300 Subject: [PATCH 01/11] Fix navigation --- .../src/components/ExplorePage/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/climatemappedafrica/src/components/ExplorePage/index.js b/apps/climatemappedafrica/src/components/ExplorePage/index.js index 4296a53b3..047b20921 100644 --- a/apps/climatemappedafrica/src/components/ExplorePage/index.js +++ b/apps/climatemappedafrica/src/components/ExplorePage/index.js @@ -80,7 +80,10 @@ function ExplorePage({ ]); useEffect(() => { if (geoCode) { - dispatch({ type: "fetch", payload: { code: geoCode } }); + dispatch({ + type: "fetch", + payload: { code: geoCode, onClick: handleClickTag }, + }); } }, [dispatch, geoCode]); @@ -94,7 +97,7 @@ function ExplorePage({ if (data) { dispatch({ type: "show", - payload: { profile: data, options: { onClick: handleClickTag } }, + payload: { profile: data, onClick: handleClickTag }, }); } }, [dispatch, data]); From e6b3e452e9a83336bd6ec1762137f0f7d9d4eb86 Mon Sep 17 00:00:00 2001 From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:02:50 +0300 Subject: [PATCH 02/11] Fix location search --- .../DropdownSearch/DownloadSearch.js | 26 ++++++++++--------- .../Navigation/ExploreNavigation/index.js | 5 ++-- .../src/lib/data/common/index.js | 7 +++-- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/apps/climatemappedafrica/src/components/DropdownSearch/DownloadSearch.js b/apps/climatemappedafrica/src/components/DropdownSearch/DownloadSearch.js index dc9f31362..a0ed0598f 100644 --- a/apps/climatemappedafrica/src/components/DropdownSearch/DownloadSearch.js +++ b/apps/climatemappedafrica/src/components/DropdownSearch/DownloadSearch.js @@ -16,7 +16,7 @@ import Link from "@/climatemappedafrica/components/Link"; function DropdownSearch({ href: hrefProp = "/explore", - label = "Search for a location", + label, locations, onClick, icon: IconProp = SearchIcon, @@ -97,15 +97,17 @@ function DropdownSearch({ return ( - ({ - color: palette.text.primary, - marginBottom: typography.pxToRem(10), - })} - > - {label} - + {label && ( + ({ + color: palette.text.primary, + marginBottom: typography.pxToRem(10), + })} + > + {label} + + )} ({ }, })); -function ExploreNavigation({ explorePagePath, logo, variant }) { +function ExploreNavigation({ explorePagePath, locations, logo, variant }) { const classes = useStyles(); const { setIsOpen } = useTour(); @@ -72,8 +72,9 @@ function ExploreNavigation({ explorePagePath, logo, variant }) { Date: Tue, 29 Oct 2024 14:07:17 +0300 Subject: [PATCH 03/11] Fix btn size Signed-off-by: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> --- .../src/components/DropdownSearch/DownloadSearch.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/climatemappedafrica/src/components/DropdownSearch/DownloadSearch.js b/apps/climatemappedafrica/src/components/DropdownSearch/DownloadSearch.js index a0ed0598f..7947622e2 100644 --- a/apps/climatemappedafrica/src/components/DropdownSearch/DownloadSearch.js +++ b/apps/climatemappedafrica/src/components/DropdownSearch/DownloadSearch.js @@ -87,8 +87,8 @@ function DropdownSearch({ component={iconComponent} viewBox="0 0 48 48" sx={{ - width: 48, - height: 48, + width: 40, + height: 40, ...iconBorder, }} /> From ae55079f2373c155b395012c39ff290b20717d2e Mon Sep 17 00:00:00 2001 From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:16:35 +0300 Subject: [PATCH 04/11] Regenerate snapshot Signed-off-by: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> --- .../src/components/DropdownSearch/DropdownSearch.snap.js | 4 ++-- apps/climatemappedafrica/src/components/Hero/Hero.snap.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/climatemappedafrica/src/components/DropdownSearch/DropdownSearch.snap.js b/apps/climatemappedafrica/src/components/DropdownSearch/DropdownSearch.snap.js index d8dd3412a..06576c3fb 100644 --- a/apps/climatemappedafrica/src/components/DropdownSearch/DropdownSearch.snap.js +++ b/apps/climatemappedafrica/src/components/DropdownSearch/DropdownSearch.snap.js @@ -12,7 +12,7 @@ exports[` renders unchanged 1`] = ` Search for a location

renders unchanged 1`] = ` > diff --git a/apps/climatemappedafrica/src/components/Hero/Hero.snap.js b/apps/climatemappedafrica/src/components/Hero/Hero.snap.js index e94a3de38..3f70167fe 100644 --- a/apps/climatemappedafrica/src/components/Hero/Hero.snap.js +++ b/apps/climatemappedafrica/src/components/Hero/Hero.snap.js @@ -60,7 +60,7 @@ exports[` renders unchanged 1`] = `
@@ -80,7 +80,7 @@ exports[` renders unchanged 1`] = ` > From d607fdda01c0094773fc8b8c64a3938ca7cd5a96 Mon Sep 17 00:00:00 2001 From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> Date: Wed, 30 Oct 2024 09:15:43 +0300 Subject: [PATCH 05/11] Deploy --- .github/workflows/climatemappedafrica-deploy-dev.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/climatemappedafrica-deploy-dev.yml b/.github/workflows/climatemappedafrica-deploy-dev.yml index 285b91405..456a1dfaa 100644 --- a/.github/workflows/climatemappedafrica-deploy-dev.yml +++ b/.github/workflows/climatemappedafrica-deploy-dev.yml @@ -2,7 +2,7 @@ name: Climate Mapped Africa | Deploy | DEV on: push: - branches: [main] + branches: [ft/climatemapped-hurumap-fixes] paths: - "apps/climatemappedafrica/**" - "Dockerfile" @@ -33,6 +33,10 @@ jobs: with: fetch-depth: 0 + # Add support for more platforms with QEMU (optional) + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -61,6 +65,7 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . + platforms: linux/arm64 target: climatemappedafrica-runner push: true tags: "${{ env.IMAGE_NAME }}:${{ github.sha }}" From b2a7d031585b0558063d8648fad816e7ae224ef8 Mon Sep 17 00:00:00 2001 From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:37:08 +0300 Subject: [PATCH 06/11] Revert Workflow file Signed-off-by: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> --- .github/workflows/climatemappedafrica-deploy-dev.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/climatemappedafrica-deploy-dev.yml b/.github/workflows/climatemappedafrica-deploy-dev.yml index 456a1dfaa..285b91405 100644 --- a/.github/workflows/climatemappedafrica-deploy-dev.yml +++ b/.github/workflows/climatemappedafrica-deploy-dev.yml @@ -2,7 +2,7 @@ name: Climate Mapped Africa | Deploy | DEV on: push: - branches: [ft/climatemapped-hurumap-fixes] + branches: [main] paths: - "apps/climatemappedafrica/**" - "Dockerfile" @@ -33,10 +33,6 @@ jobs: with: fetch-depth: 0 - # Add support for more platforms with QEMU (optional) - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -65,7 +61,6 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . - platforms: linux/arm64 target: climatemappedafrica-runner push: true tags: "${{ env.IMAGE_NAME }}:${{ github.sha }}" From e90e3a4c6a9cb619f79820b8e3274766d7754e42 Mon Sep 17 00:00:00 2001 From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:23:33 +0300 Subject: [PATCH 07/11] Fetch profile once --- .../src/lib/data/blockify/explore-page.js | 8 ++--- .../src/lib/data/blockify/index.js | 10 +++++-- .../src/lib/data/common/index.js | 29 +++++++++++++++---- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/apps/climatemappedafrica/src/lib/data/blockify/explore-page.js b/apps/climatemappedafrica/src/lib/data/blockify/explore-page.js index 53e8e8fc2..a586e6cb8 100644 --- a/apps/climatemappedafrica/src/lib/data/blockify/explore-page.js +++ b/apps/climatemappedafrica/src/lib/data/blockify/explore-page.js @@ -1,16 +1,12 @@ -import { - fetchProfile, - fetchProfileGeography, -} from "@/climatemappedafrica/lib/hurumap"; +import { fetchProfileGeography } from "@/climatemappedafrica/lib/hurumap"; -async function explorePage({ block: { slugs }, hurumap }) { +async function explorePage({ block: { slugs }, hurumap, hurumapProfile }) { const { rootGeography, page: { value }, } = hurumap; const { code: name } = rootGeography; const code = slugs.length ? slugs[0] : name; - const hurumapProfile = await fetchProfile(); const { locations, preferredChildren, mapType, choropleth } = hurumapProfile; diff --git a/apps/climatemappedafrica/src/lib/data/blockify/index.js b/apps/climatemappedafrica/src/lib/data/blockify/index.js index d8a83f9fe..5337adfb3 100644 --- a/apps/climatemappedafrica/src/lib/data/blockify/index.js +++ b/apps/climatemappedafrica/src/lib/data/blockify/index.js @@ -12,13 +12,19 @@ const propsifyBlockBySlug = { tutorial, }; -export const blockify = async (blocks, api, context, hurumap) => { +export const blockify = async ( + blocks, + api, + context, + hurumap, + hurumapProfile, +) => { const promises = blocks?.map(async (block) => { const slug = block.blockType; const propsifyBlock = propsifyBlockBySlug[slug]; if (propsifyBlock) { - return propsifyBlock({ block, api, context, hurumap }); + return propsifyBlock({ block, api, context, hurumap, hurumapProfile }); } return { ...block, diff --git a/apps/climatemappedafrica/src/lib/data/common/index.js b/apps/climatemappedafrica/src/lib/data/common/index.js index 81f110f14..a502b32dc 100644 --- a/apps/climatemappedafrica/src/lib/data/common/index.js +++ b/apps/climatemappedafrica/src/lib/data/common/index.js @@ -35,8 +35,8 @@ function getFooter(siteSettings, variant) { }; } -async function getNavBar(siteSettings, variant, { slug }) { - const { locations } = await fetchProfile(); +async function getNavBar(siteSettings, variant, { slug }, hurumapProfile) { + const { locations } = hurumapProfile; const { connect: { links = [] }, primaryNavigation: { menus = [], connect = [] }, @@ -65,6 +65,8 @@ export async function getPageProps(api, context) { const { draftMode = false } = context; const options = { draft: draftMode }; + const hurumapProfile = await fetchProfile(); + const { docs: [page], } = await api.findPage(slug, options); @@ -78,12 +80,23 @@ export async function getPageProps(api, context) { page: { value: explorePage }, } = hurumap; - let blocks = await blockify(page.blocks, api, context, hurumap); + let blocks = await blockify( + page.blocks, + api, + context, + hurumap, + hurumapProfile, + ); const variant = page.slug === explorePage.slug ? "explore" : "default"; const siteSettings = await api.findGlobal("settings-site"); const footer = getFooter(siteSettings, variant); - const menus = await getNavBar(siteSettings, variant, explorePage); + const menus = await getNavBar( + siteSettings, + variant, + explorePage, + hurumapProfile, + ); if (slug === explorePage.slug) { // The explore page is a special case. The only block we need to render is map and tutorial. @@ -96,7 +109,13 @@ export async function getPageProps(api, context) { blockType: "tutorial", }, ]; - blocks = await blockify(explorePageBlocks, api, context, hurumap); + blocks = await blockify( + explorePageBlocks, + api, + context, + hurumap, + hurumapProfile, + ); } return { From 2b64a8ce8f06befca6af17acaa07a356d9600f58 Mon Sep 17 00:00:00 2001 From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> Date: Thu, 31 Oct 2024 10:48:31 +0300 Subject: [PATCH 08/11] Fix How it works mobile view --- .../src/components/HowItWorks/index.js | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/apps/climatemappedafrica/src/components/HowItWorks/index.js b/apps/climatemappedafrica/src/components/HowItWorks/index.js index 155c23933..21835efea 100644 --- a/apps/climatemappedafrica/src/components/HowItWorks/index.js +++ b/apps/climatemappedafrica/src/components/HowItWorks/index.js @@ -56,7 +56,15 @@ function HowItWorks({ })} />
- + ({ + marginBottom: { + xs: theme.typography.pxToRem(23), + md: 0, + }, + })} > ({ From 245bc7751ffbd8e090646b2a832044f89fb1a66c Mon Sep 17 00:00:00 2001 From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:25:25 +0300 Subject: [PATCH 09/11] FIx Grid --- apps/climatemappedafrica/src/components/HowItWorks/index.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/apps/climatemappedafrica/src/components/HowItWorks/index.js b/apps/climatemappedafrica/src/components/HowItWorks/index.js index 21835efea..9b3dd3d90 100644 --- a/apps/climatemappedafrica/src/components/HowItWorks/index.js +++ b/apps/climatemappedafrica/src/components/HowItWorks/index.js @@ -165,12 +165,6 @@ function HowItWorks({ xs: "center", md: "flex-end", }} - sx={(theme) => ({ - marginBottom: { - xs: theme.typography.pxToRem(23), - md: 0, - }, - })} > ({ From 4e9016e2076f1e105f185e4991bdf3ff924abde3 Mon Sep 17 00:00:00 2001 From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> Date: Fri, 1 Nov 2024 01:16:26 +0300 Subject: [PATCH 10/11] Common settings Signed-off-by: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> --- .../src/lib/data/blockify/index.js | 9 ++------- .../src/lib/data/common/index.js | 20 +++++++------------ 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/apps/climatemappedafrica/src/lib/data/blockify/index.js b/apps/climatemappedafrica/src/lib/data/blockify/index.js index 5337adfb3..b89ee1313 100644 --- a/apps/climatemappedafrica/src/lib/data/blockify/index.js +++ b/apps/climatemappedafrica/src/lib/data/blockify/index.js @@ -12,13 +12,8 @@ const propsifyBlockBySlug = { tutorial, }; -export const blockify = async ( - blocks, - api, - context, - hurumap, - hurumapProfile, -) => { +export const blockify = async (blocks, api, context, settings) => { + const { hurumap, hurumapProfile } = settings; const promises = blocks?.map(async (block) => { const slug = block.blockType; const propsifyBlock = propsifyBlockBySlug[slug]; diff --git a/apps/climatemappedafrica/src/lib/data/common/index.js b/apps/climatemappedafrica/src/lib/data/common/index.js index a502b32dc..7fb75928c 100644 --- a/apps/climatemappedafrica/src/lib/data/common/index.js +++ b/apps/climatemappedafrica/src/lib/data/common/index.js @@ -79,17 +79,17 @@ export async function getPageProps(api, context) { const { page: { value: explorePage }, } = hurumap; + const siteSettings = await api.findGlobal("settings-site"); - let blocks = await blockify( - page.blocks, - api, - context, + const settings = { hurumap, hurumapProfile, - ); + siteSettings, + }; + + let blocks = await blockify(page.blocks, api, context, settings); const variant = page.slug === explorePage.slug ? "explore" : "default"; - const siteSettings = await api.findGlobal("settings-site"); const footer = getFooter(siteSettings, variant); const menus = await getNavBar( siteSettings, @@ -109,13 +109,7 @@ export async function getPageProps(api, context) { blockType: "tutorial", }, ]; - blocks = await blockify( - explorePageBlocks, - api, - context, - hurumap, - hurumapProfile, - ); + blocks = await blockify(explorePageBlocks, api, context, settings); } return { From f7f0dd5dfc41756f20548c037437ff45cdc54a9d Mon Sep 17 00:00:00 2001 From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> Date: Fri, 1 Nov 2024 01:21:38 +0300 Subject: [PATCH 11/11] Update failing tests --- apps/climatemappedafrica/src/components/Hero/Hero.snap.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/apps/climatemappedafrica/src/components/Hero/Hero.snap.js b/apps/climatemappedafrica/src/components/Hero/Hero.snap.js index 47322e6c2..6b4302a5f 100644 --- a/apps/climatemappedafrica/src/components/Hero/Hero.snap.js +++ b/apps/climatemappedafrica/src/components/Hero/Hero.snap.js @@ -58,11 +58,7 @@ exports[` renders unchanged 1`] = ` Search for a location