From 40acc6954d84bb89f53bef128b315669f24a9714 Mon Sep 17 00:00:00 2001 From: Rachel Partridge Date: Fri, 8 Mar 2024 09:08:55 -0800 Subject: [PATCH] show partner logos in addition to authority logos (#143) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ⚠️ DO NOT MERGE: blocked by API changes. Also note that cypress test failures are expected until API code is merged ## Description use new `data_partners` field to pull those logos and display them ## Test Plan test locally with the API PR: https://github.com/rewiringamerica/api.rewiringamerica.org/pull/341 you should see the new logo --- src/api/calculator-types-v1.ts | 10 ++++++++++ src/{authority-logos.tsx => partner-logos.tsx} | 18 +++++++++++------- src/state-incentive-details.tsx | 4 ++-- 3 files changed, 23 insertions(+), 9 deletions(-) rename src/{authority-logos.tsx => partner-logos.tsx} (68%) diff --git a/src/api/calculator-types-v1.ts b/src/api/calculator-types-v1.ts index 10326fc..56ecc7a 100644 --- a/src/api/calculator-types-v1.ts +++ b/src/api/calculator-types-v1.ts @@ -89,6 +89,16 @@ export interface APIResponse { state: string | null; utility: string | null; }; + data_partners: { + [id: string]: { + name: string; + logo?: { + src: string; + width: number; + height: number; + }; + }; + }; location: APILocation; incentives: Incentive[]; } diff --git a/src/authority-logos.tsx b/src/partner-logos.tsx similarity index 68% rename from src/authority-logos.tsx rename to src/partner-logos.tsx index a6034b8..f892631 100644 --- a/src/authority-logos.tsx +++ b/src/partner-logos.tsx @@ -7,22 +7,26 @@ type Props = { response: APIResponse }; * Displays the white area at the bottom of the calculator results with logos * of the authorities whose incentives are displayed. */ -export const AuthorityLogos = ({ response }: Props) => { +export const PartnerLogos = ({ response }: Props) => { const { msg } = useTranslated(); const authoritiesWithLogo = Object.entries(response.authorities).filter( ([, auth]) => !!auth.logo, ); - if (authoritiesWithLogo.length === 0) { + const partnersWithLogo = Object.entries(response.data_partners).filter( + ([, partner]) => !!partner.logo, + ); + const allLogos = [...authoritiesWithLogo, ...partnersWithLogo]; + if (allLogos.length === 0) { return <>; } - const logos = authoritiesWithLogo.map(([id, auth]) => ( + const logos = allLogos.map(([id, partner]) => ( {auth.name} )); diff --git a/src/state-incentive-details.tsx b/src/state-incentive-details.tsx index 26add2a..d0a6df2 100644 --- a/src/state-incentive-details.tsx +++ b/src/state-incentive-details.tsx @@ -7,7 +7,6 @@ import { Incentive, ItemType, } from './api/calculator-types-v1'; -import { AuthorityLogos } from './authority-logos'; import { PrimaryButton, TextButton } from './buttons'; import { Card } from './card'; import { TextInput } from './components/text-input'; @@ -16,6 +15,7 @@ import { str } from './i18n/str'; import { MsgFn, useTranslated } from './i18n/use-translated'; import { IconTabBar } from './icon-tab-bar'; import { ExclamationPoint, UpRightArrow } from './icons'; +import { PartnerLogos } from './partner-logos'; import { PROJECTS, Project, shortLabel } from './projects'; import { Separator } from './separator'; @@ -446,7 +446,7 @@ export const StateIncentives: FC = ({ // We won't show the empty state in this seciton, so no email submission emailSubmitter={null} /> - + ); };