From f5fe891696040a6b6e6392220ed741c7d0b59bcb Mon Sep 17 00:00:00 2001 From: developersteve Date: Thu, 7 Nov 2024 11:15:38 +1000 Subject: [PATCH] #112 added team member, advisor and partner output --- apps/.DS_Store | Bin 8196 -> 0 bytes apps/website/public/sitemap-0.xml | 6 +- .../website/src/app/hooks/strapi/UseStrapi.ts | 77 +++--- apps/website/src/app/hooks/strapi/requests.ts | 80 +++++- apps/website/src/app/hooks/strapi/types.ts | 53 +++- apps/website/src/app/page.tsx | 2 +- apps/website/src/app/team/page.tsx | 239 +++++++----------- .../SocialProofSection/SocialProofSection.tsx | 2 +- 8 files changed, 260 insertions(+), 199 deletions(-) delete mode 100644 apps/.DS_Store diff --git a/apps/.DS_Store b/apps/.DS_Store deleted file mode 100644 index 4c5c8b7781ee16bf0d86cc2338e051f80c32e15f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHMYitx%6h7ayz>JJAtrZF~*{v;)V6iQt@(^6w@{(52wsc!i+}#=4k?Bm`ncV`3 zro{M4Ofx2oi&_nuwO%hbVo%oAFIs%v64Sg;yW%BV$~zB~oba&GsH*ZF z4Q8Weyrb^3_(yj8mhfmrD`tbaTvhjq`HrH^qny@Pn$4P#Q+oprkaW?aw`oS8^&WJ* z*mRA4i)vU}pPS3uuJpD}-=G>hwf?f)xty%iZ&$T!!5;6;-RxA2&(wRxjk|I| zxNFq*DnF^++^(vF!Eml18E!!B5S9U^vN}L@Gr9f@WbjnB4m{}QLNFa)0tkqS-7{%dW(lT1hhe2B^QhYd3B_pO!L(=YKQOyjMYnx0KDHhs0*p1+u`cG&6H*|u2q*HX7&R{m?!axcua3j`m zrfJbGBzOh`rbc8$)n#Kj(gkG7jM|j^JTDg2(VUp5V-X4$tES9K%bT{jYNV zPv8x_iMQ|pj^iVIj87sSOyURpgr6_S?Cz~c@hbA4}!^(yR`>LQW;1pc29Ky_zNXFKn0ruVR@wbR`1<1U)e8 -https://lilypad.tech/team2024-10-25T00:33:13.305Zdaily0.7 -https://lilypad.tech2024-10-25T00:33:13.314Zdaily0.7 -https://lilypad.tech/about-us2024-10-25T00:33:13.314Zdaily0.7 +https://lilypad.tech/about-us2024-11-07T00:24:52.741Zdaily0.7 +https://lilypad.tech2024-11-07T00:24:52.743Zdaily0.7 +https://lilypad.tech/team2024-11-07T00:24:52.743Zdaily0.7 \ No newline at end of file diff --git a/apps/website/src/app/hooks/strapi/UseStrapi.ts b/apps/website/src/app/hooks/strapi/UseStrapi.ts index ecc2684..08cfb99 100644 --- a/apps/website/src/app/hooks/strapi/UseStrapi.ts +++ b/apps/website/src/app/hooks/strapi/UseStrapi.ts @@ -1,67 +1,56 @@ import { useEffect, useState } from "react"; -import { getHomepageInfo, getTrustedBy } from "./requests"; -import { HomePageCmsInfo, StrapiProps, StrapiResponse } from "./types"; +import { getHomepageInfo, getTrustedBy, getTeamCore, getTeamAdvisors, getTeamPartners } from "./requests"; +import { HomePageCmsInfo, TeamPageCmsInfo, StrapiProps, StrapiResponse } from "./types"; function useStrapi({ pathname }: StrapiProps): StrapiResponse { const [isLoading, setIsLoading] = useState(true); - const [strapi, setStrapi] = useState({}); + const [strapi, setStrapi] = useState({}); + const getData = () => { switch (pathname) { case "/": Promise.allSettled([getHomepageInfo(), getTrustedBy()]) .then((results) => { - const homepageInfoResp = - results[0] as PromiseFulfilledResult; - const trustedByResp = - results[1] as PromiseFulfilledResult; - if ( - homepageInfoResp.status === "fulfilled" && - trustedByResp.status === "fulfilled" - ) { + const homepageInfoResp = results[0]; + const trustedByResp = results[1]; - const homepageData = homepageInfoResp.value as HomePageCmsInfo; - - setStrapi((prevState: HomePageCmsInfo) => { - return { - ...prevState, - ...homepageData, - trusted_bies: trustedByResp.value, - }; - }); + if (homepageInfoResp.status === "fulfilled" && trustedByResp.status === "fulfilled") { + setStrapi((prevState) => ({ + ...prevState, + ...(homepageInfoResp.value as HomePageCmsInfo), + trusted_bies: trustedByResp.value || [], + })); } }) - .catch(() => { - throw new Error("Failed to fetch strapi data"); - }) - .finally(() => { - setIsLoading(false); - }); + .finally(() => setIsLoading(false)); break; + case "/team": - Promise.allSettled([getTrustedBy()]) - .then((results) => { - const trustedByResp = - results[0] as PromiseFulfilledResult; - if (trustedByResp.status === "fulfilled") { - setStrapi((prevState: HomePageCmsInfo) => { - return { - ...prevState, - trusted_bies: trustedByResp.value, - }; - }); - } - }) - .finally(() => { - setIsLoading(false); - }); - break; + Promise.allSettled([getTeamCore(), getTeamAdvisors(), getTeamPartners()]) + .then((results) => { + const teamCoreResp = results[0]; + const advisorsResp = results[1]; + const partnersResp = results[2]; + + setStrapi((prevState) => ({ + ...prevState, + teamMembers: teamCoreResp.status === "fulfilled" ? teamCoreResp.value : [], + advisors: advisorsResp.status === "fulfilled" ? advisorsResp.value : [], + partners: partnersResp.status === "fulfilled" ? partnersResp.value : [], + })); + }) + .finally(() => setIsLoading(false)); + break; + default: setIsLoading(false); } }; + useEffect(() => { getData(); - }, []); + }, [pathname]); + return { strapi, isLoading }; } diff --git a/apps/website/src/app/hooks/strapi/requests.ts b/apps/website/src/app/hooks/strapi/requests.ts index 0c79221..ee50a58 100644 --- a/apps/website/src/app/hooks/strapi/requests.ts +++ b/apps/website/src/app/hooks/strapi/requests.ts @@ -1,8 +1,8 @@ import { TrustedByInfo } from "./types"; const cms_base_url = process.env.NEXT_PUBLIC_STRAPI_URL; -//remove /api from base_url and to home_url variable const cms_home_url = cms_base_url?.replace("/api", ""); + export function getHomepageInfo() { return new Promise((resolve, reject) => { fetch(`${cms_base_url}/website-homepage`, { @@ -21,7 +21,6 @@ export function getHomepageInfo() { }); } - export function getTrustedBy() { return new Promise((resolve, reject) => { fetch( @@ -46,3 +45,80 @@ export function getTrustedBy() { }); }); } + +export function getTeamAdvisors() { + return new Promise((resolve, reject) => { + fetch(`${cms_base_url}/team-advisors?populate[Image][fields][0]=url`, { + headers: { authorization: `Bearer ${process.env.NEXT_PUBLIC_STRAPI_API}` }, + }) + .then((data) => data.json()) + .then(({ data }) => { + const advisorsData = data.map((advisor: any) => ({ + id: advisor.id, + documentId: advisor.documentId, + Name: advisor.Name, + Title: advisor.Title, + blurb: advisor.blurb, + twitter: advisor.twitter, + linkedin: advisor.linkedin, + website: advisor.website, + Image: advisor.Image ? { url: advisor.Image.url } : null, // Extract Image URL if present + })); + resolve(advisorsData); + }) + .catch((err) => reject(err)); + }); +} + +export function getTeamPartners() { + return new Promise((resolve, reject) => { + fetch(`${cms_base_url}/team-partners?populate[Image][fields][0]=url`, { + headers: { authorization: `Bearer ${process.env.NEXT_PUBLIC_STRAPI_API}` }, + }) + .then((data) => data.json()) + .then(({ data }) => { + const partnersData = data.map((partner: any) => ({ + id: partner.id, + documentId: partner.documentId, + Name: partner.Name, + Title: partner.Title, + blurb: partner.blurb, + twitter: partner.twitter, + linkedin: partner.linkedin, + website: partner.website, + Image: partner.Image ? { url: partner.Image.url } : null, // Extract Image URL if present + })); + resolve(partnersData); + }) + .catch((err) => reject(err)); + }); +} + +export function getTeamCore() { + return new Promise((resolve, reject) => { + fetch( + `${cms_base_url}/team-cores?populate[Image][fields][0]=url`, // Ensure Image field is populated + { + headers: { + authorization: `Bearer ${process.env.NEXT_PUBLIC_STRAPI_API}`, + }, + } + ) + .then((data) => data.json()) + .then(({ data }) => { + const teamCoreData = data.map((member: any) => ({ + id: member.id, + documentId: member.documentId, + Name: member.Name, + Title: member.Title, + blurb: member.blurb, + twitter: member.twitter, + linkedin: member.linkedin, + website: member.website, + Image: member.Image ? { url: member.Image.url } : null, // Extract Image URL if present + })); + resolve(teamCoreData); + }) + .catch((err) => reject(err)); + }); +} diff --git a/apps/website/src/app/hooks/strapi/types.ts b/apps/website/src/app/hooks/strapi/types.ts index c477eab..4d9fc77 100644 --- a/apps/website/src/app/hooks/strapi/types.ts +++ b/apps/website/src/app/hooks/strapi/types.ts @@ -1,5 +1,5 @@ export interface StrapiContext { - strapi: HomePageCmsInfo | Object; + strapi: HomePageCmsInfo | TeamPageCmsInfo | Object; } export interface HomePageCmsInfo { @@ -14,22 +14,69 @@ export interface HomePageCmsInfo { alt: string; }[]; } + export interface TeamPageCmsInfo { trusted_bies: { src: string; alt: string; }[]; + teamMembers: { + id: number; + documentId: string; + Name: string; + Title: string; + blurb: string; + twitter: string; + linkedin: string; + website: string; + Image?: { url: string } | null; + }[]; + advisors: { + id: number; + documentId: string; + Name: string; + Title: string; + blurb: string; + twitter: string; + linkedin: string; + website: string; + Image?: { url: string } | null; + }[]; + partners: { + id: number; + documentId: string; + Name: string; + Title: string; + blurb: string; + twitter: string; + linkedin: string; + website: string; + Image?: { url: string } | null; + }[]; } + +export interface TeamMemberInfo { + name: string; + image: string; + title: string; + blurb: string; + twitter?: string; + linkedin?: string; + website?: string; +} + export interface TrustedByInfo { alt: string; image: { url: string; }; } + export interface StrapiResponse { - strapi: HomePageCmsInfo | Object; - isLoading: Boolean; + strapi: HomePageCmsInfo | TeamPageCmsInfo | Object; + isLoading: boolean; } + export interface StrapiProps { pathname: string; } diff --git a/apps/website/src/app/page.tsx b/apps/website/src/app/page.tsx index 6df28a6..42517bb 100644 --- a/apps/website/src/app/page.tsx +++ b/apps/website/src/app/page.tsx @@ -277,7 +277,7 @@ export default function Home() { "_blank" ) } - badge={strapi?.badge_badge} + badge="leading" icon={{ url: arrowsArrowRight, }} diff --git a/apps/website/src/app/team/page.tsx b/apps/website/src/app/team/page.tsx index 5605dd2..a0d3501 100644 --- a/apps/website/src/app/team/page.tsx +++ b/apps/website/src/app/team/page.tsx @@ -15,9 +15,13 @@ import { PageContext } from "../clientLayout"; import { TeamPageCmsInfo } from "../hooks/strapi/types"; export default function Teams() { - const { strapi } = useContext(PageContext) as { - strapi: TeamPageCmsInfo; - }; + + const { strapi } = useContext(PageContext) as { strapi: TeamPageCmsInfo }; + + const teamMembers = strapi?.teamMembers || []; + const advisors = strapi?.advisors || []; + const partners = strapi?.partners || []; + const socialLinks = [ { href: "twitter.com", iconUrl: "/x.svg" }, @@ -31,83 +35,6 @@ export default function Teams() { }, ]; - const trustedByArray = [ - { src: "/bacalhau.svg", alt: "Bacalhau" }, - { src: "/bacalhau.svg", alt: "Filecoin" }, - { src: "/bacalhau.svg", alt: "Holon" }, - { src: "/bacalhau.svg", alt: "Protocol Labs" }, - { src: "/bacalhau.svg", alt: "Rare Compute" }, - { src: "/bacalhau.svg", alt: "Spheron" }, - { src: "/bacalhau.svg", alt: "Swan" }, - ]; - - const teamMembers = [ - { - src: "/dummy-image-1.png", - title: "Olivia Rhye", - position: "Founder & CEO", - description: - "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", - socialIcons: socialLinks, - }, - { - src: "/dummy-image-2.png", - title: "Phoenix Baker", - position: "Chief Marketing Officer", - description: - "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", - socialIcons: socialLinks, - }, - { - src: "/dummy-image-3.png", - title: "Liam James", - position: "Chief Technology Officer", - description: - "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", - socialIcons: socialLinks, - }, - { - src: "/dummy-image-1.png", - title: "Olivia Rhye", - position: "Founder & CEO", - description: - "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", - socialIcons: socialLinks, - }, - { - src: "/dummy-image-2.png", - title: "Phoenix Baker", - position: "Chief Marketing Officer", - description: - "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", - socialIcons: socialLinks, - }, - { - src: "/dummy-image-3.png", - title: "Liam James", - position: "Chief Technology Officer", - description: - "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", - socialIcons: socialLinks, - }, - { - src: "/dummy-image-2.png", - title: "Phoenix Baker", - position: "Chief Marketing Officer", - description: - "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", - socialIcons: socialLinks, - }, - { - src: "/dummy-image-1.png", - title: "Phoenix Baker", - position: "Chief Marketing Officer", - description: - "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", - socialIcons: socialLinks, - }, - ]; - const [teamSection2Ref, teamSection2Springs] = useFadeInView(); const [teamSection3Ref, teamSection3Springs] = useFadeInView(); const fadeLandingspage = useFade(); @@ -167,79 +94,101 @@ export default function Teams() {
- {teamMembers.map((member, index) => ( - - <_TeamMember - key={index} - src={member.src} - title={member.title} - position={member.position} - description={member.description} - socialIcons={member.socialIcons} - /> - - ))} + {teamMembers.length > 0 ? ( + teamMembers.map((member, index) => ( + + <_TeamMember + src={ + member.Image && member.Image.url + ? `https://webadmin.lilypad.team${member.Image.url}` + : "/default-image.png" // Use a default image if none exists + } + title={member.Name} + position={member.Title} + description={member.blurb} + socialIcons={[ + { href: `https://twitter.com/${member.twitter}`, iconUrl: "/x.svg" }, + { href: `https://linkedin.com/in/${member.linkedin}`, iconUrl: "/linkedin.svg" }, + { href: member.website, iconUrl: mapsAndTravelGlobe02 }, + ]} + /> + + )) + ) : ( +

No team members found.

+ )}
+
- - + + - - {teamMembers.map((member, index) => ( - <_TeamMember - key={index} - src={member.src} - title={member.title} - position={member.position} - description={member.description} - socialIcons={member.socialIcons} - /> - ))} - - + + {advisors.length > 0 ? ( + advisors.map((advisor, index) => ( + <_TeamMember + key={index} + src={advisor.Image?.url ? `https://webadmin.lilypad.team${advisor.Image.url}` : "/default-image.png"} + title={advisor.Name} + position={advisor.Title} + description={advisor.blurb} + socialIcons={[ + { href: `https://twitter.com/${advisor.twitter}`, iconUrl: "/x.svg" }, + { href: `https://linkedin.com/in/${advisor.linkedin}`, iconUrl: "/linkedin.svg" }, + { href: advisor.website, iconUrl: mapsAndTravelGlobe02 }, + ]} + /> + )) + ) : ( +

No advisors found.

+ )} +
+
+ - - - {teamMembers.map((member, index) => ( - <_TeamMember - key={index} - src={member.src} - title={member.title} - position={member.position} - description={member.description} - socialIcons={member.socialIcons} - /> - ))} - - + + + {partners.length > 0 ? ( + partners.map((partner, index) => ( + <_TeamMember + key={index} + src={partner.Image?.url ? `https://webadmin.lilypad.team${partner.Image.url}` : "/default-image.png"} + title={partner.Name} + position={partner.Title} + description={partner.blurb} + socialIcons={[ + { href: `https://twitter.com/${partner.twitter}`, iconUrl: "/x.svg" }, + { href: `https://linkedin.com/in/${partner.linkedin}`, iconUrl: "/linkedin.svg" }, + { href: partner.website, iconUrl: mapsAndTravelGlobe02 }, + ]} + /> + )) + ) : ( +

No partners found.

+ )} +
+
-
- - - -
+ ); diff --git a/apps/website/src/components/SocialProofSection/SocialProofSection.tsx b/apps/website/src/components/SocialProofSection/SocialProofSection.tsx index bdc68a0..d0eb7ab 100644 --- a/apps/website/src/components/SocialProofSection/SocialProofSection.tsx +++ b/apps/website/src/components/SocialProofSection/SocialProofSection.tsx @@ -20,7 +20,7 @@ const SocialProofSection = ({ {title}
- {trustedByArray.map(({ src, alt }, index) => { + {(trustedByArray || []).map(({ src, alt }, index) => { return (