diff --git a/apps/charterafrica/src/components/EcosystemList/EcosystemFilter.js b/apps/charterafrica/src/components/EcosystemList/EcosystemFilter.js
index eb218ad16..fc2330599 100644
--- a/apps/charterafrica/src/components/EcosystemList/EcosystemFilter.js
+++ b/apps/charterafrica/src/components/EcosystemList/EcosystemFilter.js
@@ -8,7 +8,8 @@ import { ControlledSearchInput } from "@/charterafrica/components/SearchInput";
const EcosystemFilter = React.forwardRef(function EcosystemFilter(props, ref) {
const { onChange, searchPlaceholder, values, filterOptions = [] } = props;
-
+ // Search input field spans 3 columns, so divide 9 by the filter options
+ const spans = Math.floor(9 / filterOptions.length);
return (
-
+
onChange({ search: e.target.value })}
@@ -31,7 +33,7 @@ const EcosystemFilter = React.forwardRef(function EcosystemFilter(props, ref) {
/>
{filterOptions.map((option) => {
- if (option.type === "select" && option.options.length) {
+ if (option?.type === "select" && option.options.length) {
const value = values[option.name] || "";
const optValue = option.options.find((opt) => value === opt.value);
@@ -39,7 +41,7 @@ const EcosystemFilter = React.forwardRef(function EcosystemFilter(props, ref) {
onChange({ [option.name]: v });
};
return (
-
+
@@ -145,7 +146,7 @@ const Tool = React.forwardRef(function Tool(props, ref) {
Collection
- Tool
+ {classification}
renders unchanged 1`] = `
>
Collection
-
- Tool
-
{
- const { search, location } = query;
+ const { search, location, classification } = query;
const fields = ["description", "fullName", "location", "externalId"];
const where = {};
if (search) {
@@ -17,6 +17,9 @@ const queryBuilder = (query) => {
if (location) {
where.location = { equals: location };
}
+ if (classification) {
+ where.classification = { equals: classification };
+ }
return where;
};
@@ -128,6 +131,12 @@ async function processPageContributors(page, api, context) {
}
const { filters, title } = blocks[foundIndex];
const filterLabels = labelsPerLocale[locale];
+ const collections = [
+ ...new Set(results.map((item) => item.classification)),
+ ].map((value) => ({
+ value: value ?? null,
+ label: value ?? null,
+ }));
const filterOptions =
filters?.map((filter) => {
if (filter === "sort") {
@@ -154,6 +163,15 @@ async function processPageContributors(page, api, context) {
})),
};
}
+ if (filter === "classification") {
+ return {
+ type: "select",
+ name: "classification",
+ label: filterLabels.collection,
+ multiple: true,
+ options: collections,
+ };
+ }
return null;
}) ?? [];
const people = {
diff --git a/apps/charterafrica/src/lib/data/common/processPageOrganisations.js b/apps/charterafrica/src/lib/data/common/processPageOrganisations.js
index bc6cdec7c..57fe7bf21 100644
--- a/apps/charterafrica/src/lib/data/common/processPageOrganisations.js
+++ b/apps/charterafrica/src/lib/data/common/processPageOrganisations.js
@@ -5,7 +5,7 @@ import formatDateTime from "@/charterafrica/utils/formatDate";
import labelsPerLocale from "@/charterafrica/utils/translationConstants";
const queryBuilder = (query) => {
- const { search, location } = query;
+ const { search, location, classification } = query;
const fields = ["description", "location", "name", "externalId", "slug"];
const where = {};
if (search) {
@@ -14,6 +14,9 @@ const queryBuilder = (query) => {
if (location) {
where.location = { equals: location };
}
+ if (classification) {
+ where.classification = { equals: classification };
+ }
return where;
};
@@ -117,6 +120,12 @@ async function processPageOrganisations(page, api, context) {
}
const { filters, title } = blocks[foundIndex];
const filterLabels = labelsPerLocale[locale];
+ const collections = [
+ ...new Set(results.map((item) => item.classification)),
+ ].map((value) => ({
+ value: value ?? null,
+ label: value ?? null,
+ }));
const filterOptions =
filters?.map((filter) => {
if (filter === "sort") {
@@ -143,6 +152,15 @@ async function processPageOrganisations(page, api, context) {
})),
};
}
+ if (filter === "classification") {
+ return {
+ type: "select",
+ name: "classification",
+ label: filterLabels.collection,
+ multiple: true,
+ options: collections,
+ };
+ }
return null;
}) ?? [];
diff --git a/apps/charterafrica/src/lib/data/common/processPageTools.js b/apps/charterafrica/src/lib/data/common/processPageTools.js
index 554bbc8a9..e2e1ccfdf 100644
--- a/apps/charterafrica/src/lib/data/common/processPageTools.js
+++ b/apps/charterafrica/src/lib/data/common/processPageTools.js
@@ -8,7 +8,7 @@ import formatDateTime from "@/charterafrica/utils/formatDate";
import labelsPerLocale from "@/charterafrica/utils/translationConstants";
const queryBuilder = (query) => {
- const { search, theme, homeCountry } = query;
+ const { search, theme, homeCountry, classification } = query;
const where = {};
if (search) {
const fields = [
@@ -19,6 +19,7 @@ const queryBuilder = (query) => {
"id",
"slug",
"homeCountry",
+ "classification",
];
where.or = fields.map((field) => ({ [field]: { like: search } }));
}
@@ -30,6 +31,9 @@ const queryBuilder = (query) => {
if (theme) {
where.theme = { equals: theme };
}
+ if (classification) {
+ where.classification = { equals: classification };
+ }
return where;
};
@@ -104,6 +108,7 @@ async function processPageSingleTool(page, api, context) {
commitText: filterLabels.lastCommit,
forksText: filterLabels.forks,
starsText: filterLabels.stars,
+ collection: tool.classification,
externalLink: {
href: tool.docLink ?? null,
},
@@ -159,6 +164,12 @@ async function processPageTools(page, api, context) {
value,
label: value,
}));
+ const collections = [...new Set(docs.map((item) => item.classification))].map(
+ (value) => ({
+ value: value ?? null,
+ label: value ?? null,
+ }),
+ );
const filterLabels = labelsPerLocale[locale];
const filterOptions = filters.map((filter) => {
if (filter === "sort") {
@@ -197,6 +208,15 @@ async function processPageTools(page, api, context) {
options: themes,
};
}
+ if (filter === "classification") {
+ return {
+ type: "select",
+ name: "classification",
+ label: filterLabels.collection,
+ multiple: true,
+ options: collections,
+ };
+ }
return null;
});
const tool = {
@@ -212,7 +232,7 @@ async function processPageTools(page, api, context) {
const { slugs, ...queryParams } = context.query;
let swrKey = `/api/v1/resources/ecosystem`;
- const qs = queryString({ ...queryParams, collection: "tools" });
+ const qs = queryString({ ...queryParams });
if (qs) {
swrKey = `${swrKey}?${qs}`;
}
diff --git a/apps/charterafrica/src/lib/ecosystem/airtable/processData.js b/apps/charterafrica/src/lib/ecosystem/airtable/processData.js
index fd78b2de3..140e19fa6 100644
--- a/apps/charterafrica/src/lib/ecosystem/airtable/processData.js
+++ b/apps/charterafrica/src/lib/ecosystem/airtable/processData.js
@@ -124,6 +124,7 @@ export function processTool(item, config, { partnersData }) {
link: getValue(data, toolTableColumns.url),
operatingCountries,
contributors: getValue(data, toolTableColumns.contributors),
+ classification: getValue(data, toolTableColumns.classification),
source,
supporters,
partners,
@@ -168,6 +169,7 @@ export function processContributor(item, config) {
);
return {
airtableId: data.id,
+ classification: getValue(data, contributorTableColumns.classification),
externalId,
repoLink,
socialMedia,
@@ -231,6 +233,7 @@ export function processOrganisation(item, config, { partnersData }) {
externalId,
type: getValue(data, organisationTableColumns.type)?.replace(/&/g, "and"),
repoLink: getValue(data, organisationTableColumns.source.url),
+ classification: getValue(data, organisationTableColumns.classification),
supporters,
partners,
socialMedia,
diff --git a/apps/charterafrica/src/payload/blocks/Contributors.js b/apps/charterafrica/src/payload/blocks/Contributors.js
index a72f8f8b1..23047d40b 100644
--- a/apps/charterafrica/src/payload/blocks/Contributors.js
+++ b/apps/charterafrica/src/payload/blocks/Contributors.js
@@ -35,6 +35,14 @@ const Contributors = {
fr: "Emplacement",
},
},
+ {
+ value: "classification",
+ label: {
+ en: "Collection",
+ fr: "Collection",
+ pt: "Coleção",
+ },
+ },
],
},
{
diff --git a/apps/charterafrica/src/payload/blocks/Organisations.js b/apps/charterafrica/src/payload/blocks/Organisations.js
index 5d022f04b..e342ad70c 100644
--- a/apps/charterafrica/src/payload/blocks/Organisations.js
+++ b/apps/charterafrica/src/payload/blocks/Organisations.js
@@ -35,6 +35,14 @@ const Contributors = {
fr: "Emplacement",
},
},
+ {
+ value: "classification",
+ label: {
+ en: "Collection",
+ fr: "Collection",
+ pt: "Coleção",
+ },
+ },
],
},
{
diff --git a/apps/charterafrica/src/payload/blocks/Tools.js b/apps/charterafrica/src/payload/blocks/Tools.js
index 1cd7ca431..db88dd729 100644
--- a/apps/charterafrica/src/payload/blocks/Tools.js
+++ b/apps/charterafrica/src/payload/blocks/Tools.js
@@ -51,6 +51,14 @@ const Tools = {
fr: "Emplacement",
},
},
+ {
+ value: "classification",
+ label: {
+ en: "Collection",
+ fr: "Collection",
+ pt: "Coleção",
+ },
+ },
],
},
],
diff --git a/apps/charterafrica/src/payload/collections/Contributors.js b/apps/charterafrica/src/payload/collections/Contributors.js
index d2215920e..62faec402 100644
--- a/apps/charterafrica/src/payload/collections/Contributors.js
+++ b/apps/charterafrica/src/payload/collections/Contributors.js
@@ -48,6 +48,19 @@ const Contributors = {
readOnly: true,
},
},
+ {
+ name: "classification",
+ type: "text",
+ admin: {
+ readOnly: true,
+ },
+ localized: true,
+ label: {
+ en: "Collection",
+ fr: "Collection",
+ pt: "Coleção",
+ },
+ },
{
name: "description",
type: "textarea",
diff --git a/apps/charterafrica/src/payload/collections/Organisations.js b/apps/charterafrica/src/payload/collections/Organisations.js
index 286ae7a6a..ffbce3431 100644
--- a/apps/charterafrica/src/payload/collections/Organisations.js
+++ b/apps/charterafrica/src/payload/collections/Organisations.js
@@ -46,6 +46,15 @@ const Organisations = {
readOnly: true,
},
},
+ {
+ name: "classification",
+ type: "text",
+ admin: {
+ readOnly: true,
+ },
+ localized: true,
+ label: { en: "Collection", fr: "Collection", pt: "Collection" },
+ },
// Can either be Non-Profit, For- Profit, Donor/ Investor, Charter Grantee
{
name: "type",
diff --git a/apps/charterafrica/src/payload/collections/Tools.js b/apps/charterafrica/src/payload/collections/Tools.js
index dcfaa3027..65c800e52 100644
--- a/apps/charterafrica/src/payload/collections/Tools.js
+++ b/apps/charterafrica/src/payload/collections/Tools.js
@@ -113,6 +113,19 @@ const Tools = {
localized: true,
label: { en: "Theme", fr: "Thème", pt: "Tema" },
},
+ {
+ name: "classification",
+ type: "text",
+ admin: {
+ readOnly: true,
+ },
+ localized: true,
+ label: {
+ en: "Collection",
+ fr: "Collection",
+ pt: "Coleção",
+ },
+ },
{
name: "techSkills",
type: "array",
diff --git a/apps/charterafrica/src/payload/globals/Ecosystem.js b/apps/charterafrica/src/payload/globals/Ecosystem.js
index 7e64e63b2..191bb54dc 100644
--- a/apps/charterafrica/src/payload/globals/Ecosystem.js
+++ b/apps/charterafrica/src/payload/globals/Ecosystem.js
@@ -296,6 +296,18 @@ const Ecosystem = {
},
},
}),
+ airtableColumnSelect({
+ schema,
+ tableField: "toolTableId",
+ overrides: {
+ name: "classification",
+ label: {
+ en: "Collection",
+ fr: "Collection",
+ pt: "Coleção",
+ },
+ },
+ }),
socialMediaColumns({ schema, tableField: "toolTableId" }),
],
},
@@ -421,6 +433,18 @@ const Ecosystem = {
hideGutter: true,
},
},
+ airtableColumnSelect({
+ schema,
+ tableField: "contributorTableId",
+ overrides: {
+ name: "classification",
+ label: {
+ en: "Collection",
+ fr: "Collection",
+ pt: "Coleção",
+ },
+ },
+ }),
socialMediaColumns({
schema,
tableField: "contributorTableId",
@@ -561,6 +585,18 @@ const Ecosystem = {
},
},
}),
+ airtableColumnSelect({
+ schema,
+ tableField: "organisationTableId",
+ overrides: {
+ name: "classification",
+ label: {
+ en: "Collection",
+ fr: "Collection",
+ pt: "Coleção",
+ },
+ },
+ }),
socialMediaColumns({
schema,
tableField: "organisationTableId",
diff --git a/apps/charterafrica/src/utils/translationConstants.js b/apps/charterafrica/src/utils/translationConstants.js
index 76a597df9..f4e5b7b4a 100644
--- a/apps/charterafrica/src/utils/translationConstants.js
+++ b/apps/charterafrica/src/utils/translationConstants.js
@@ -30,6 +30,8 @@ const labelsPerLocale = {
discussions: "Discussions",
lastCommit: "Last Commit",
forks: "Forks",
+ collection: "Collection",
+ classification: "Classification",
},
fr: {
topic: "Sujet A-Z",
@@ -62,6 +64,8 @@ const labelsPerLocale = {
discussions: "Discussions",
lastCommit: "Dernier Commit",
forks: "Forks",
+ collection: "Collection",
+ classification: "Classification",
},
pt: {
topic: "Tópico A-Z",
@@ -94,6 +98,8 @@ const labelsPerLocale = {
discussions: "Discussões",
lastCommit: "Último Commit",
forks: "Forks",
+ collection: "Collection",
+ classification: "classificação",
},
};