diff --git a/apps/charterafrica/contrib/dokku/Dockerfile b/apps/charterafrica/contrib/dokku/Dockerfile index 1179499c8..51856b529 100644 --- a/apps/charterafrica/contrib/dokku/Dockerfile +++ b/apps/charterafrica/contrib/dokku/Dockerfile @@ -1 +1 @@ -FROM codeforafrica/charterafrica-ui:0.1.23 +FROM codeforafrica/charterafrica-ui:0.1.24 diff --git a/apps/charterafrica/package.json b/apps/charterafrica/package.json index 52b417cdf..8c0a09b3f 100644 --- a/apps/charterafrica/package.json +++ b/apps/charterafrica/package.json @@ -1,6 +1,6 @@ { "name": "charterafrica", - "version": "0.1.23", + "version": "0.1.24", "private": true, "author": "Code for Africa ", "description": "This is the official code for https://charter.africa site", diff --git a/apps/charterafrica/src/lib/data/common/processPageContributors.js b/apps/charterafrica/src/lib/data/common/processPageContributors.js index 415f2fca5..1796a0cc6 100644 --- a/apps/charterafrica/src/lib/data/common/processPageContributors.js +++ b/apps/charterafrica/src/lib/data/common/processPageContributors.js @@ -1,4 +1,4 @@ -import { allCountries } from "@/charterafrica/lib/data/json/countries"; +import { allCountries } from "@/charterafrica/lib/data/json/locations"; import { CONTRIBUTORS_COLLECTION, TOOL_COLLECTION, diff --git a/apps/charterafrica/src/lib/data/common/processPageOrganisations.js b/apps/charterafrica/src/lib/data/common/processPageOrganisations.js index 57fe7bf21..62487df90 100644 --- a/apps/charterafrica/src/lib/data/common/processPageOrganisations.js +++ b/apps/charterafrica/src/lib/data/common/processPageOrganisations.js @@ -1,4 +1,4 @@ -import { allCountries } from "@/charterafrica/lib/data/json/countries"; +import { allCountries } from "@/charterafrica/lib/data/json/locations"; import { ORGANIZATION_COLLECTION } from "@/charterafrica/payload/utils/collections"; import queryString from "@/charterafrica/utils/ecosystem/queryString"; import formatDateTime from "@/charterafrica/utils/formatDate"; diff --git a/apps/charterafrica/src/lib/data/common/processPageTools.js b/apps/charterafrica/src/lib/data/common/processPageTools.js index e2e1ccfdf..c665ef92f 100644 --- a/apps/charterafrica/src/lib/data/common/processPageTools.js +++ b/apps/charterafrica/src/lib/data/common/processPageTools.js @@ -1,4 +1,4 @@ -import { allCountries } from "@/charterafrica/lib/data/json/countries"; +import { allLocations } from "@/charterafrica/lib/data/json/locations"; import { TOOL_COLLECTION, ORGANIZATION_COLLECTION, @@ -193,7 +193,7 @@ async function processPageTools(page, api, context) { type: "select", name: "homeCountry", label: filterLabels.location, - options: allCountries.map((country) => ({ + options: allLocations.map((country) => ({ value: country.value, label: country.label?.[locale || "en"], })), diff --git a/apps/charterafrica/src/lib/data/json/countries.js b/apps/charterafrica/src/lib/data/json/locations.js similarity index 98% rename from apps/charterafrica/src/lib/data/json/countries.js rename to apps/charterafrica/src/lib/data/json/locations.js index aef932f88..fac2f4de6 100644 --- a/apps/charterafrica/src/lib/data/json/countries.js +++ b/apps/charterafrica/src/lib/data/json/locations.js @@ -1961,12 +1961,26 @@ const countries = [ }, ]; -export const countriesByContinent = (continent) => { - return countries +const regions = [ + { + name: "Africa", + label: { + pt: "África", + en: "Africa", + fr: "Afrique", + }, + value: "Africa", + continent: "Africa", + }, +]; +const locations = [...countries, ...regions]; +const toOptions = ({ label, value }) => ({ label, value }); + +export const locationsByContinent = (continent) => { + return locations .filter((country) => continent === country.continent) - .map(({ continent: cntnt, name, ...c }) => c); + .map(toOptions); }; -export const allCountries = countries.map( - ({ continent: cntnt, name, ...c }) => c, -); +export const allCountries = countries.map(toOptions); +export const allLocations = locations.map(toOptions); diff --git a/apps/charterafrica/src/lib/openAfrica.js b/apps/charterafrica/src/lib/openAfrica.js index 54e7f95bb..3af420e60 100644 --- a/apps/charterafrica/src/lib/openAfrica.js +++ b/apps/charterafrica/src/lib/openAfrica.js @@ -1,13 +1,13 @@ import * as Sentry from "@sentry/nextjs"; -import { countriesByContinent } from "@/charterafrica/lib/data/json/countries"; +import { locationsByContinent } from "@/charterafrica/lib/data/json/locations"; import fetchJson from "@/charterafrica/utils/fetchJson"; const OPEN_AFRICA_URL = "https://open.africa/"; const OPEN_AFRICA_BASE_API_URL = `${OPEN_AFRICA_URL}api/3/action/`; const PAGE_SIZE = 10; const AFRICA_COUNTRIES_BY_LOCALE = ["en", "fr", "pt"].reduce((acc, cur) => { - acc[cur] = countriesByContinent("Africa").map(({ label, value }) => ({ + acc[cur] = locationsByContinent("Africa").map(({ label, value }) => ({ value: value.toLowerCase(), label: label[cur], })); diff --git a/apps/charterafrica/src/payload/collections/Tools.js b/apps/charterafrica/src/payload/collections/Tools.js index 65c800e52..381306ac0 100644 --- a/apps/charterafrica/src/payload/collections/Tools.js +++ b/apps/charterafrica/src/payload/collections/Tools.js @@ -1,7 +1,7 @@ import { - allCountries, - countriesByContinent, -} from "../../lib/data/json/countries"; + allLocations, + locationsByContinent, +} from "../../lib/data/json/locations"; import avatarUrl from "../fields/avatarUrl"; import dateField from "../fields/dateField"; import slug from "../fields/slug"; @@ -93,7 +93,7 @@ const Tools = { { name: "operatingCountries", type: "select", - options: countriesByContinent("Africa"), + options: locationsByContinent("Africa"), label: { en: "Operating Countries", fr: "Pays opérationnels", @@ -272,7 +272,7 @@ const Tools = { { name: "homeCountry", type: "select", - options: allCountries, + options: allLocations, label: { en: "Home Country", fr: "Pays natal", pt: "País natal" }, admin: { readOnly: true,