Skip to content

Commit

Permalink
Merge pull request #549 from CodeForAfrica/bug/fix-charter-issues
Browse files Browse the repository at this point in the history
Fix Charterafrica issues
  • Loading branch information
koechkevin authored Aug 10, 2023
2 parents 9e3afc3 + 1a88a17 commit a327f0c
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 38 deletions.
4 changes: 3 additions & 1 deletion apps/charterafrica/src/components/Infographic/Infographic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import { Box } from "@mui/material";
import Script from "next/script";
import React from "react";

import site from "@/charterafrica/utils/site";

const Infographic = React.forwardRef(function Infographic(props, ref) {
const {
countriesFile: countriesFileProp,
dataFile: dataFileProp,
infographicId: id,
sx,
url,
} = props;

const { url } = site;
if (!(id && url)) {
return null;
}
Expand Down
9 changes: 8 additions & 1 deletion apps/charterafrica/src/components/Tool/Contributors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { RichTypography } from "@commons-ui/core";
import { Link } from "@commons-ui/next";
import { Avatar, AvatarGroup, Box } from "@mui/material";
import PropTypes from "prop-types";
import React from "react";
Expand All @@ -16,7 +17,13 @@ const Contributors = React.forwardRef(function Contributors(props, ref) {
</RichTypography>
<AvatarGroup sx={{ justifyContent: { xs: "center", sm: "right" } }}>
{list.map((item) => (
<Avatar key={item.id} alt={item.name} src={item.avatarUrl} />
<Avatar
key={item.id}
component={Link}
href={item.link.href}
alt={item.name}
src={item.avatarUrl}
/>
))}
</AvatarGroup>
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RichTypography } from "@commons-ui/core";
import { Figure } from "@commons-ui/next";
import { Figure, Link } from "@commons-ui/next";
import { Box, Button } from "@mui/material";
import PropTypes from "prop-types";
import React from "react";
Expand All @@ -23,14 +23,15 @@ const OrgThemeAndOperatingCountries = React.forwardRef(
width: "auto",
}}
/>
<RichTypography
<Link
href={organisation?.link?.href || "#"}
textAlign="left"
color="neutral.dark"
sx={{ fontWeight: 400 }}
variant="h4"
sx={{ textDecoration: "none" }}
variant="h3Small"
>
{organisation.name}
</RichTypography>
</Link>
{theme ? (
<Button
variant="contained"
Expand Down
28 changes: 16 additions & 12 deletions apps/charterafrica/src/components/Tool/Tool.snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,9 @@ exports[`<Tool /> renders unchanged 1`] = `
+
26
</div>
<div
class="MuiAvatar-root MuiAvatar-circular MuiAvatar-colorDefault MuiAvatarGroup-avatar css-r3976x-MuiAvatar-root"
<a
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways MuiAvatar-root MuiAvatar-circular MuiAvatar-colorDefault MuiAvatarGroup-avatar active css-1sel0v5-MuiTypography-root-MuiLink-root-MuiAvatar-root"
href=""
>
<svg
aria-hidden="true"
Expand All @@ -264,9 +265,10 @@ exports[`<Tool /> renders unchanged 1`] = `
d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"
/>
</svg>
</div>
<div
class="MuiAvatar-root MuiAvatar-circular MuiAvatar-colorDefault MuiAvatarGroup-avatar css-r3976x-MuiAvatar-root"
</a>
<a
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways MuiAvatar-root MuiAvatar-circular MuiAvatar-colorDefault MuiAvatarGroup-avatar active css-1sel0v5-MuiTypography-root-MuiLink-root-MuiAvatar-root"
href=""
>
<svg
aria-hidden="true"
Expand All @@ -279,9 +281,10 @@ exports[`<Tool /> renders unchanged 1`] = `
d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"
/>
</svg>
</div>
<div
class="MuiAvatar-root MuiAvatar-circular MuiAvatar-colorDefault MuiAvatarGroup-avatar css-r3976x-MuiAvatar-root"
</a>
<a
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways MuiAvatar-root MuiAvatar-circular MuiAvatar-colorDefault MuiAvatarGroup-avatar active css-1sel0v5-MuiTypography-root-MuiLink-root-MuiAvatar-root"
href=""
>
<svg
aria-hidden="true"
Expand All @@ -294,9 +297,10 @@ exports[`<Tool /> renders unchanged 1`] = `
d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"
/>
</svg>
</div>
<div
class="MuiAvatar-root MuiAvatar-circular MuiAvatar-colorDefault MuiAvatarGroup-avatar css-r3976x-MuiAvatar-root"
</a>
<a
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways MuiAvatar-root MuiAvatar-circular MuiAvatar-colorDefault MuiAvatarGroup-avatar active css-1sel0v5-MuiTypography-root-MuiLink-root-MuiAvatar-root"
href=""
>
<svg
aria-hidden="true"
Expand All @@ -309,7 +313,7 @@ exports[`<Tool /> renders unchanged 1`] = `
d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"
/>
</svg>
</div>
</a>
</div>
</div>
</div>
Expand Down
16 changes: 0 additions & 16 deletions apps/charterafrica/src/lib/data/common/processPageIndex.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import site from "@/charterafrica/utils/site";

const processHero = (page) => {
const { blocks } = page;
const heroIndex = blocks.findIndex((block) => block.slug === "hero");
Expand Down Expand Up @@ -34,19 +32,6 @@ const processHero = (page) => {
}
};

const processInfographic = (page) => {
const { blocks } = page;
const infographicIndex = blocks.findIndex(
(block) => block.slug === "aga-infographic",
);

const infographic = blocks[infographicIndex] ?? null;
if (infographic) {
const { url } = site;
blocks[infographicIndex] = { ...infographic, url };
}
};

const processSpotlight = (page, api, context) => {
const { blocks } = page;
const { locale } = context;
Expand Down Expand Up @@ -101,7 +86,6 @@ const processMooc = (page) => {

async function processPageIndex(page, api, context) {
processHero(page);
processInfographic(page);
processMooc(page);
processSpotlight(page, api, context);

Expand Down
9 changes: 8 additions & 1 deletion apps/charterafrica/src/lib/data/common/processPageTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ async function processPageSingleTool(page, api, context) {
});
const tools = [];
const filterLabels = labelsPerLocale[locale];
const organisationPage = await getPageUrl(api, "organisations");
const organisation = orgDocs?.[0]
? {
...orgDocs?.[0],
link: { href: `${organisationPage}/${orgDocs?.[0].slug}` },
}
: null;
return {
...page,
blocks: [
Expand Down Expand Up @@ -90,7 +97,7 @@ async function processPageSingleTool(page, api, context) {
email: tool.organisation?.email ?? null,
location: tool.organisation?.location ?? null,
description: tool.description ?? null,
organisation: orgDocs?.[0] ?? null,
organisation,
supportersTitle: filterLabels.supporters,
partnersTitle: filterLabels.partners,
contributorsText: filterLabels.contributors,
Expand Down
2 changes: 0 additions & 2 deletions apps/charterafrica/src/lib/ecosystem/airtable/processData.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ export function processContributor(
);
return {
airtableId: data.id,
avatarUrl:
getValue(data, contributorTableColumns.avatarUrl)?.[0]?.url ?? null,
externalId,
repoLink,
socialMedia,
Expand Down

0 comments on commit a327f0c

Please sign in to comment.