Closes #111 Blocked by !158 Co-authored-by: Jared He <66887902+jaredjhe@users.noreply.github.com> Co-authored-by: Aditya Thakral <a3thakra@csclub.uwaterloo.ca> Reviewed-on: #159 Reviewed-by: Aditya Thakral <a3thakra@csclub.uwaterloo.ca> Co-authored-by: j285he <j285he@localhost> Co-committed-by: j285he <j285he@localhost>
This commit is contained in:
parent
e548bd9c5a
commit
5933dd03b8
|
@ -104,7 +104,13 @@ export async function getUpcomingEvents(): Promise<Event[]> {
|
|||
});
|
||||
}
|
||||
|
||||
export async function getProps(year: string, term: string): Promise<Props> {
|
||||
export async function getEventsPageProps({
|
||||
year,
|
||||
term,
|
||||
}: {
|
||||
year: string;
|
||||
term: string;
|
||||
}): Promise<Props> {
|
||||
const eventNames = await getEventsByTerm(year, term);
|
||||
|
||||
const events: Event[] = (
|
||||
|
|
|
@ -9,7 +9,7 @@ import { Link } from "@/components/Link";
|
|||
import { MiniEventCard } from "@/components/MiniEventCard";
|
||||
import {
|
||||
Event,
|
||||
getProps,
|
||||
getEventsPageProps,
|
||||
getEventYears,
|
||||
getEventTermsByYear,
|
||||
} from "@/lib/events";
|
||||
|
@ -61,7 +61,7 @@ export default function Term(props: Props) {
|
|||
key={link.year + link.term}
|
||||
/>
|
||||
))}
|
||||
<Link href="/events/archives">Archives</Link>
|
||||
<Link href="/events/archive">Archive</Link>
|
||||
</div>
|
||||
{hasFutureEvents && (
|
||||
<>
|
||||
|
@ -88,6 +88,14 @@ export default function Term(props: Props) {
|
|||
</span>
|
||||
</h2>
|
||||
)}
|
||||
{!hasFutureEvents && !hasPastEvents && (
|
||||
<>
|
||||
<h2>Events</h2>
|
||||
There are no upcoming or past events for the{" "}
|
||||
{`${capitalize(props.term)} ${props.year}`} term. Please check back
|
||||
later!
|
||||
</>
|
||||
)}
|
||||
<div className={styles.miniEventCards}>
|
||||
{props.pastEvents.map(({ content, metadata }) => (
|
||||
<MiniEventCard
|
||||
|
@ -125,9 +133,7 @@ export const getStaticProps: GetStaticProps<Props, Params> = async (
|
|||
context
|
||||
) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const { year, term } = context.params!;
|
||||
|
||||
return { props: await getProps(year, term) };
|
||||
return { props: await getEventsPageProps(context.params!) };
|
||||
};
|
||||
|
||||
export const getStaticPaths: GetStaticPaths<Params> = async () => {
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
import { GetStaticProps } from "next";
|
||||
|
||||
import { getCurrentTerm, getEventsPageProps } from "@/lib/events";
|
||||
|
||||
import Term, { Props } from "./[year]/[term]/index";
|
||||
|
||||
export default Term;
|
||||
|
||||
export const getStaticProps: GetStaticProps<Props> = async () => {
|
||||
return { props: await getEventsPageProps(getCurrentTerm()) };
|
||||
};
|
Loading…
Reference in New Issue