Skip to content

Commit

Permalink
Merge pull request #114 from Lilypad-Tech/developersteve/team
Browse files Browse the repository at this point in the history
#112 added team member, advisor and partner output
  • Loading branch information
developersteve authored Nov 7, 2024
2 parents bf64f5f + f5fe891 commit affdff5
Show file tree
Hide file tree
Showing 8 changed files with 260 additions and 199 deletions.
Binary file removed apps/.DS_Store
Binary file not shown.
6 changes: 3 additions & 3 deletions apps/website/public/sitemap-0.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url><loc>https://lilypad.tech/team</loc><lastmod>2024-10-25T00:33:13.305Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://lilypad.tech</loc><lastmod>2024-10-25T00:33:13.314Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://lilypad.tech/about-us</loc><lastmod>2024-10-25T00:33:13.314Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://lilypad.tech/about-us</loc><lastmod>2024-11-07T00:24:52.741Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://lilypad.tech</loc><lastmod>2024-11-07T00:24:52.743Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://lilypad.tech/team</loc><lastmod>2024-11-07T00:24:52.743Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
</urlset>
77 changes: 33 additions & 44 deletions apps/website/src/app/hooks/strapi/UseStrapi.ts
Original file line number Diff line number Diff line change
@@ -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<boolean>(true);
const [strapi, setStrapi] = useState<HomePageCmsInfo | Object>({});
const [strapi, setStrapi] = useState<HomePageCmsInfo | TeamPageCmsInfo | Object>({});

const getData = () => {
switch (pathname) {
case "/":
Promise.allSettled([getHomepageInfo(), getTrustedBy()])
.then((results) => {
const homepageInfoResp =
results[0] as PromiseFulfilledResult<unknown>;
const trustedByResp =
results[1] as PromiseFulfilledResult<unknown>;
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<unknown>;
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 };
}

Expand Down
80 changes: 78 additions & 2 deletions apps/website/src/app/hooks/strapi/requests.ts
Original file line number Diff line number Diff line change
@@ -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`, {
Expand All @@ -21,7 +21,6 @@ export function getHomepageInfo() {
});
}


export function getTrustedBy() {
return new Promise((resolve, reject) => {
fetch(
Expand All @@ -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));
});
}
53 changes: 50 additions & 3 deletions apps/website/src/app/hooks/strapi/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface StrapiContext {
strapi: HomePageCmsInfo | Object;
strapi: HomePageCmsInfo | TeamPageCmsInfo | Object;
}

export interface HomePageCmsInfo {
Expand All @@ -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;
}
2 changes: 1 addition & 1 deletion apps/website/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export default function Home() {
"_blank"
)
}
badge={strapi?.badge_badge}
badge="leading"
icon={{
url: arrowsArrowRight,
}}
Expand Down
Loading

0 comments on commit affdff5

Please sign in to comment.