This repository has been archived by the owner on Aug 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix build error, add section times to schedule page, and redact
unreleased assignments
- Loading branch information
Showing
9 changed files
with
156 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import Link from "next/link" | ||
import { FormattedDate } from "./FormattedDate" | ||
import { allAssessments, allHomework } from "contentlayer/generated" | ||
|
||
export type Assignment = { | ||
title: string | ||
href: string | ||
isReleased: boolean | ||
releaseDate?: Date | ||
dates: { | ||
name: string | ||
date: Date | ||
specifyTime: boolean | ||
}[] | ||
sortDate: Date | ||
} | ||
|
||
export const formattedHomework: Assignment[] = allHomework.map(hw => { | ||
const due = new Date(hw.dueDate) | ||
|
||
return { | ||
title: hw.title, | ||
href: `/assignments/hw/${hw.slug}`, | ||
isReleased: hw.isReleased, | ||
releaseDate: hw.releaseDate && new Date(hw.releaseDate), | ||
dates: [ | ||
...(hw.auxiliaryDates ?? []).map(aux => ({ | ||
name: aux.name, | ||
date: new Date(aux.date), | ||
specifyTime: true, | ||
})), | ||
{ | ||
name: "Due", | ||
date: due, | ||
specifyTime: true, | ||
} | ||
], | ||
sortDate: new Date(hw.dueDate), | ||
} | ||
}) | ||
|
||
export const formattedAssessments = allAssessments.map(a => { | ||
const date = new Date(a.assessmentDate) | ||
|
||
return { | ||
title: a.title, | ||
href: `/assignments/assessment/${a.slug}`, | ||
isReleased: a.isReleased, | ||
releaseDate: a.releaseDate && new Date(a.releaseDate), | ||
dates: [ | ||
{ | ||
name: "Scheduled", | ||
date, | ||
specifyTime: false, | ||
} | ||
], | ||
sortDate: date, | ||
} | ||
}) | ||
|
||
export function AssignmentRow({ title, href, isReleased, releaseDate, dates }: Assignment) { | ||
let className = "border-b border-neutral-300 dark:border-neutral-600 py-2 last:pb-0 last:border-0 block lg:table-row w-full" | ||
if (!isReleased) { | ||
className += " opacity-50" | ||
} | ||
|
||
return <tr className={className}> | ||
<td className="lg:py-2 w-full block lg:table-cell"> | ||
{isReleased ? | ||
<Link href={href} className="link font-bold">{title}</Link> : | ||
<span className="italic">{title}{releaseDate && <> (available <strong><FormattedDate date={releaseDate} format="M/d" /></strong>)</>}</span>} | ||
</td> | ||
<td className="lg:py-2 block lg:table-cell"> | ||
{dates.map((item, index) => <div key={index}> | ||
{item.name} <strong><FormattedDate date={item.date} format={item.specifyTime ? "E, M/d @ h:mmaa" : "E, M/d"} /></strong> | ||
</div>)} | ||
</td> | ||
</tr> | ||
} | ||
|
||
export function AssignmentTable({ assignments: raw }: { assignments: Assignment[] }) { | ||
const data = raw.toSorted((a, b) => a.sortDate.getTime() - b.sortDate.getTime()) | ||
|
||
return <table className="block lg:table w-full"> | ||
<thead> | ||
<tr className="border-b-4 border-neutral-300 dark:border-neutral-600 sr-only lg:not-sr-only"> | ||
<th className="text-left pb-2 w-full">Name</th> | ||
<th className="text-left pb-2 lg:min-w-64">Date</th> | ||
</tr> | ||
</thead> | ||
<tbody className="block lg:table-row-group"> | ||
{data.map(assignment => <AssignmentRow {...assignment} key={assignment.href} />)} | ||
</tbody> | ||
</table> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,10 @@ | ||
["201", "202"] | ||
[ | ||
{ | ||
"id": "201", | ||
"time": "Thursdays 7pm" | ||
}, | ||
{ | ||
"id": "202", | ||
"time": "Mondays 5:15pm" | ||
} | ||
] |