Skip to content

Commit

Permalink
feat: organizer page now fetching from Sanity
Browse files Browse the repository at this point in the history
  • Loading branch information
waalbert committed Jul 27, 2023
1 parent 4802377 commit 2b6822a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 37 deletions.
4 changes: 2 additions & 2 deletions apps/site/src/app/about/TeamCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import styles from "./TeamCard.module.scss";
interface TeamCardProps {
name: string;
position: string;
image: string;
linkedInUrl: string;
image: string | undefined;
linkedInUrl: string | undefined;
}
const TeamCard = ({ name, position, image, linkedInUrl }: TeamCardProps) => {
return (
Expand Down
16 changes: 9 additions & 7 deletions apps/site/src/app/about/TeamSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import TeamCard from "./TeamCard";
import styles from "./TeamSection.module.scss";

type Member = {
name: string;
person: {
name: string;
profilePic?: { asset: { url: string } };
socials?: { link: string };
};
position: string;
image: string;
linkedInUrl: string;
};

interface TeamSection {
Expand All @@ -21,11 +23,11 @@ const TeamSection = ({ team, members }: TeamSection) => {
<div className={styles.teamGrid}>
{members.map((member) => (
<TeamCard
key={member.name}
name={member.name}
key={member.person.name}
name={member.person.name}
position={member.position}
image={member.image}
linkedInUrl={member.linkedInUrl}
image={member.person.profilePic?.asset.url}
linkedInUrl={member.person.socials?.link}
/>
))}
</div>
Expand Down
42 changes: 14 additions & 28 deletions apps/site/src/app/about/getMembers.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
const FEED_URL = "https://docs.google.com/spreadsheets/d/";
const SPREADSHEET_KEY = "1DWCOQBlzA3mpa2BXYXPmQrF9_-SpoPFbTdDQuCQ83hU";
const QUERY = "pub";
const FORMAT = "output=tsv";

const dataURL = FEED_URL + SPREADSHEET_KEY + "/" + QUERY + "?" + FORMAT;

const getSheetsData = async (page: string) => {
const response = await fetch(dataURL);

if (response.status !== 200)
console.warn(
"Error ocurred while fetching schedule data:",
response.statusText
);

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);
}
}

return null;
};

export const getMembers = async () => await getSheetsData("members");
import { cache } from "react";
import { client } from "@/lib/sanity/sanityClient";

export const getMembers = cache(async () => {
return await client
.fetch(
`*[_type == 'boardYear'][0]{corporate[]{person->{name, profilePic{asset->{url}}, socials[0]{link}}, position},
logistics[]{person->{name, profilePic{asset->{url}}, socials[0]{link}}, position},
marketing[]{person->{name, profilePic{asset->{url}}, socials[0]{link}}, position},
tech[]{person->{name, profilePic{asset->{url}}, socials[0]{link}}, position}}`
)
.then((result) => result)
.catch((error) => console.warn(error));
});

0 comments on commit 2b6822a

Please sign in to comment.