-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Changes from all commits
2b6822a
ddc7a8a
ccbb98d
0679ca0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(), | ||
}) | ||
Comment on lines
+19
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: why is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR is focused on pulling content from Sanity, so the Zod schema here is just validating what's returned from Sanity. As far as I can remember, we decided to separate the Person object from organizers to make it more reusable. For example, people may switch to different departments between years, or we may decided to use the Person object as an author field in the future. The profile photo was something we discussed at the time, but ultimately decided that it wasn't worth the extra complexity. Might be something we have to revisit in the future? cc @samderanova There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding on to what Alex already mentioned, there might be former organizers that we might want to display on other sections of the site in the future (ex. alumni showcases). In situations like those, it would be better to just have one schema for all of our people and then use them in other schemas where needed instead of having two schemas to do the same. |
||
); | ||
|
||
if (response.status !== 200) | ||
console.warn( | ||
"Error ocurred while fetching schedule data:", | ||
response.statusText | ||
); | ||
export const Members = z.object({ | ||
corporate: Department, | ||
alexanderl19 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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} | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replacing |
||
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 | ||
}, | ||
}` | ||
alexanderl19 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
export const getMembers = async () => await getSheetsData("members"); | ||
}); |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue: this asset seems quite large, is this official or made with a vectorizer? The color is also slightly off from the LinkedIn Blue. Would prefer to avoid diverging from brand guidelines. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chore: if we're replacing the logo icon, could we remove the older version.