Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Organizer page is now fetching from Sanity #21

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
alexanderl19 marked this conversation as resolved.
Show resolved Hide resolved
}
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}
alexanderl19 marked this conversation as resolved.
Show resolved Hide resolved
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
alexanderl19 marked this conversation as resolved.
Show resolved Hide resolved
.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}}`
alexanderl19 marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This groq query can probably be condensed a bit.

Something like the following should work since we don't need the asset url anymore.

*[_type == 'boardYear'] | order(year desc) [0]{
  corporate[]{
    person->{
      name,
      profilePic,
      socials[0] {link}
    },
    position
  },
  logistics[]{
    person->{
      name,
      profilePic,
      socials[0] {link}
    },
    position
  },
  marketing[]{
    person->{
      name,
      profilePic,
      socials[0] {link}
    },
    position
  },
  tech[]{
    person->{
      name,
      profilePic,
      socials[0] {link}
    },
    position
  }, 
}

Copy link
Contributor

@alexanderl19 alexanderl19 Jul 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't catch this the first time around, but we probably shouldn't assume the LinkedIn link is the first one in the array. I'll come up with an updated groq query later and reply here.

)
.then((result) => result)
alexanderl19 marked this conversation as resolved.
Show resolved Hide resolved
.catch((error) => console.warn(error));
alexanderl19 marked this conversation as resolved.
Show resolved Hide resolved
});