Skip to content

Commit

Permalink
Update country to use code
Browse files Browse the repository at this point in the history
  • Loading branch information
koechkevin committed Oct 12, 2023
1 parent f72cbc7 commit 62213a8
Show file tree
Hide file tree
Showing 3 changed files with 2,503 additions and 2,503 deletions.
12 changes: 6 additions & 6 deletions apps/codeforafrica/src/lib/data/blockify/ourTeam.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { countries } from "@/codeforafrica/lib/data/json/countries";
import { getMembers } from "@/codeforafrica/lib/data/utils/members";
import { sortTags } from "@/codeforafrica/lib/data/utils/tags";
import { sortTags, ALL_TAG } from "@/codeforafrica/lib/data/utils/tags";
import equalsIgnoreCase from "@/codeforafrica/utils/equalsIgnoreCase";

const getCountryFromName = (name) =>
countries.find((c) => equalsIgnoreCase(c.slug, name)) ?? null;
const getCountryFromCode = (alpha3) =>
countries.find((c) => equalsIgnoreCase(c.alpha3, alpha3)) ?? null;

function getTeamTags(docs) {
const tags = sortTags(docs.map((item) => item.team).filter(Boolean));
return [{ name: "All", slug: "All" }, ...tags];
return [ALL_TAG, ...tags];
}

function getCountryTags(docs) {
const tags = sortTags(
docs.map(({ country }) => getCountryFromName(country)).filter(Boolean),
docs.map(({ country }) => getCountryFromCode(country)).filter(Boolean),
);
return [{ name: "All", slug: "All" }, ...tags];
return [ALL_TAG, ...tags];
}

async function getTags(fields, docs) {
Expand Down
Loading

0 comments on commit 62213a8

Please sign in to comment.