diff --git a/apps/site/src/app/about/TeamCard.tsx b/apps/site/src/app/about/TeamCard.tsx index a3c59b1..345d74d 100644 --- a/apps/site/src/app/about/TeamCard.tsx +++ b/apps/site/src/app/about/TeamCard.tsx @@ -1,9 +1,15 @@ +import { z } from "zod"; /* eslint-disable @next/next/no-img-element */ import type { StaticImageData } from "next/image"; import clsx from "clsx"; // could we replace with something like simple-icons (https://github.com/simple-icons/simple-icons)? -import linkedinLogo from "@/lib/common/assets/icons/linkedin.svg"; +import linkedinLogo from "@/lib/common/assets/linkedin-logo.svg"; import blank from "./blank.png"; +import { client } from "@/lib/sanity/sanityClient"; +import { SanityImageReference } from "@/lib/sanity/types"; +import imageUrlBuilder from "@sanity/image-url"; + +const urlBuilder = imageUrlBuilder(client); import styles from "./TeamCard.module.scss"; @@ -16,18 +22,23 @@ import styles from "./TeamCard.module.scss"; // // + interface TeamCardProps { name: string; position: string; - image: string; - linkedInUrl: string; + image: z.infer | null; + linkedInUrl?: string; } const TeamCard = ({ name, position, image, linkedInUrl }: TeamCardProps) => { return (
{name} diff --git a/apps/site/src/app/about/TeamSection.tsx b/apps/site/src/app/about/TeamSection.tsx index bfb0dbb..3ef93b1 100644 --- a/apps/site/src/app/about/TeamSection.tsx +++ b/apps/site/src/app/about/TeamSection.tsx @@ -1,13 +1,17 @@ import clsx from "clsx"; import TeamCard from "./TeamCard"; +import { z } from "zod"; +import { SanityImageReference } from "@/lib/sanity/types"; import styles from "./TeamSection.module.scss"; type Member = { - name: string; + person: { + name: string; + profilePic: z.infer | null; + socials: { link: string } | null; + }; position: string; - image: string; - linkedInUrl: string; }; interface TeamSection { @@ -21,11 +25,11 @@ const TeamSection = ({ team, members }: TeamSection) => {
{members.map((member) => ( ))}
diff --git a/apps/site/src/app/about/getMembers.ts b/apps/site/src/app/about/getMembers.ts index f763b47..c633a56 100644 --- a/apps/site/src/app/about/getMembers.ts +++ b/apps/site/src/app/about/getMembers.ts @@ -1,28 +1,78 @@ -const FEED_URL = "https://docs.google.com/spreadsheets/d/"; -const SPREADSHEET_KEY = "1DWCOQBlzA3mpa2BXYXPmQrF9_-SpoPFbTdDQuCQ83hU"; -const QUERY = "pub"; -const FORMAT = "output=tsv"; +import { z } from "zod"; +import { cache } from "react"; +import { client } from "@/lib/sanity/sanityClient"; +import { SanityImageReference } from "@/lib/sanity/types"; -const dataURL = FEED_URL + SPREADSHEET_KEY + "/" + QUERY + "?" + FORMAT; +const Person = z.object({ + _type: z.literal("person"), + name: z.string(), + profilePic: SanityImageReference.nullable(), + socials: z + .object({ + link: z.string(), + }) + .nullable(), +}); -const getSheetsData = async (page: string) => { - const response = await fetch(dataURL); +const Department = z.array( + z.object({ + person: Person, + position: z.string(), + }) +); - if (response.status !== 200) - console.warn( - "Error ocurred while fetching schedule data:", - response.statusText - ); +export const Members = z.object({ + corporate: Department, + logistics: Department, + marketing: Department, + tech: Department, +}); - const csv = await response.text(); - for (const line of csv.split("\n")) { - const [key, value] = line.split("\t"); - if (key === page) { - return JSON.parse(value); - } +export const getMembers = cache(async () => { + try { + return Members.parse( + await client.fetch( + `*[_type == 'boardYear'] | order(year desc) [0]{ + corporate[]{ + person->{ + _type, + name, + profilePic, + socials[0] {link} + }, + position + }, + logistics[]{ + person->{ + _type, + name, + profilePic, + socials[0] {link} + }, + position + }, + marketing[]{ + person->{ + _type, + name, + profilePic, + socials[0] {link} + }, + position + }, + tech[]{ + person->{ + _type, + name, + profilePic, + socials[0] {link} + }, + position + }, + }` + ) + ); + } catch (error) { + console.error(error); } - - return null; -}; - -export const getMembers = async () => await getSheetsData("members"); +}); diff --git a/apps/site/src/app/about/page.tsx b/apps/site/src/app/about/page.tsx index 0cd37c2..a59e1a5 100644 --- a/apps/site/src/app/about/page.tsx +++ b/apps/site/src/app/about/page.tsx @@ -20,6 +20,10 @@ export const metadata: Metadata = { export default async function Home() { const teamMembers = await getMembers(); + if (teamMembers === undefined) { + throw new Error("teamMembers is undefined"); + } + return (
@@ -48,7 +52,6 @@ export default async function Home() {
{Object.entries(teamMembers).map(([team, members]) => ( - // @ts-expect-error ))}
diff --git a/apps/site/src/lib/common/assets/linkedin-logo.png b/apps/site/src/lib/common/assets/linkedin-logo.png new file mode 100644 index 0000000..56ba168 Binary files /dev/null and b/apps/site/src/lib/common/assets/linkedin-logo.png differ diff --git a/apps/site/src/lib/common/assets/linkedin-logo.svg b/apps/site/src/lib/common/assets/linkedin-logo.svg new file mode 100644 index 0000000..358274a --- /dev/null +++ b/apps/site/src/lib/common/assets/linkedin-logo.svg @@ -0,0 +1,142 @@ + + + + + + + \ No newline at end of file