Skip to content
Merged
Changes from all commits
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
44 changes: 41 additions & 3 deletions src/templates/schedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,47 @@ import ScheduleList, {
ScheduleSession,
} from "../components/Conf/Schedule/ScheduleList"

const ScheduleTemplate: FC<PageProps<{}, { schedule: ScheduleSession[] }>> = ({
pageContext: { schedule },
}) => {
const fetchData = async (url: string) => {
try {
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"User-Agent": "GraphQL Conf / GraphQL Foundation",
},
})
const data = await response.json()
return data
} catch (error: any) {
throw new Error(
`Error fetching data from ${url}: ${error.message || error.toString()}`
)
}
}

export async function getServerData() {
try {
const schedule: ScheduleSession[] = await fetchData(
`https://graphqlconf23.sched.com/api/session/list?api_key=${process.env.SCHED_ACCESS_TOKEN}&format=json`
)

return {
props: {
schedule,
},
}
} catch (error) {
return {
status: 500,
headers: {},
props: {},
}
}
}

const ScheduleTemplate: FC<
PageProps<{}, {}, {}, { schedule: ScheduleSession[] }>
> = ({ serverData: { schedule } }) => {
return (
<LayoutConf>
<HeaderConf className="shadow-none" />
Expand Down