-
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 3 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,91 @@ | ||
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); | ||
export const Members = z.object({ | ||
corporate: z.array( | ||
alexanderl19 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
z.object({ | ||
person: Person, | ||
position: z.string(), | ||
}) | ||
), | ||
logistics: z.array( | ||
z.object({ | ||
person: Person, | ||
position: z.string(), | ||
}) | ||
), | ||
marketing: z.array( | ||
z.object({ | ||
person: Person, | ||
position: z.string(), | ||
}) | ||
), | ||
tech: 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 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
|
||
) | ||
); | ||
|
||
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); | ||
} | ||
} 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.