Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions components/ReusableTimetable/Timetable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ const Timetable: React.FC<{

timetableList.push({
...class_,
isTA: lesson.isTA || false,
pushDown,
minutesUntilPrevClass: 0,
id: `${class_.moduleCode}-${class_.lessonType}-${class_.classNo}`,
Expand Down
27 changes: 9 additions & 18 deletions components/ReusableTimetable/TimetableSelectable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ const TimetableSelectable: React.FC<{
// const showSmallerText = useBreakpointValue()

const weeksDisplay = combineNumbersDatabase(class_.weeks);
const moduleLabelParts: string[] = [];
if (showModuleCode) moduleLabelParts.push(class_.moduleCode);
if (showLessonType) {
moduleLabelParts.push(encodeLessonTypeToShorthand(class_.lessonType));
}
const moduleLabel = moduleLabelParts.join(" ") + (class_.isTA && moduleLabelParts.length ? " (TA)" : "");

const toggleHandler = () => {
// handleSelect(class_, !sel)
Expand Down Expand Up @@ -127,12 +133,7 @@ const TimetableSelectable: React.FC<{
<Stack spacing={0}>
{(showModuleCode || showLessonType) && (
<Text fontSize={{ base: "xs", md: "sm" }}>
{showModuleCode ? class_.moduleCode : ""}{" "}
{showLessonType
? encodeLessonTypeToShorthand(
class_.lessonType
)
: ""}
{moduleLabel}
</Text>
)}
<Flex flexWrap={"wrap"} alignItems="center">
Expand Down Expand Up @@ -247,12 +248,7 @@ const TimetableSelectable: React.FC<{
<Stack spacing={0}>
{(showModuleCode || showLessonType) && (
<Text fontSize={{ base: "xs", md: "sm" }}>
{showModuleCode ? class_.moduleCode : ""}{" "}
{showLessonType
? encodeLessonTypeToShorthand(
class_.lessonType
)
: ""}
{moduleLabel}
</Text>
)}
<Flex flexWrap={"wrap"}>
Expand Down Expand Up @@ -339,12 +335,7 @@ const TimetableSelectable: React.FC<{
<Stack spacing={0}>
{(showModuleCode || showLessonType) && (
<Text fontSize={{ base: "xs", md: "sm" }}>
{showModuleCode ? class_.moduleCode : ""}{" "}
{showLessonType
? encodeLessonTypeToShorthand(
class_.lessonType
)
: ""}
{moduleLabel}
</Text>
)}
<Flex flexWrap={"wrap"}>
Expand Down
19 changes: 10 additions & 9 deletions lib/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const LESSON_TYPE_FULL = {

// SEC
export const encodeLessonTypeToShorthand = (
string: keyof LessonTypeAbbrevMap
string: keyof LessonTypeAbbrevMap,
) => {
if (LESSON_TYPE_ABBREV[string]) return LESSON_TYPE_ABBREV[string];
else return string.substring(0, 3).toUpperCase();
Expand Down Expand Up @@ -121,7 +121,8 @@ export const canBeBidFor = (moduleCode: string, lessonType: string) => {
return !(
lessonType.toLocaleLowerCase().startsWith("lec") ||
moduleCode.toUpperCase().startsWith("RV") ||
moduleCode.toUpperCase().startsWith("UT")
moduleCode.toUpperCase().startsWith("UT") ||
lessonType.toUpperCase() === "TA"
);
};

Expand Down Expand Up @@ -177,7 +178,7 @@ export const combineNumbers = (numbers: (string | number)[]) => {
// Function to generate the NUSMods Timetable Link based on the modules selected
export const generateLink = (
classesSelected: ModuleCodeLessonType,
priority = 0
priority = 0,
) => {
const holder: {
[moduleCode: string]: ClassOverview[];
Expand Down Expand Up @@ -205,7 +206,7 @@ export const generateLink = (
(classes) =>
`${encodeLessonTypeToShorthand(classes.lessonType)}:${
classes.classNo
}`
}`,
)
.join(",")
: "";
Expand Down Expand Up @@ -357,7 +358,7 @@ export const formatDate = (date: Date) => {
export const encodeRank = (
rank: ClassOverview[],
moduleOrder: string[],
selectedClasses: ModuleCodeLessonType
selectedClasses: ModuleCodeLessonType,
) => {
// let begin = `https://tutreg.com/?share=`;
// let ranked = [];
Expand All @@ -376,7 +377,7 @@ export const encodeRank = (
(class_) =>
`${class_.moduleCode}:${encodeLessonTypeToShorthand(class_.lessonType)}:${
class_.classNo
}`
}`,
);
begin += ranked.join(",");

Expand Down Expand Up @@ -409,7 +410,7 @@ export const tutregToNUSMods = (url: string) => {
for (let class_ of selectedClasses) {
const moduleCode: string = class_.split(":")[0];
const abbreLessonType: LessonTypeAbbrev = class_.split(
":"
":",
)[1] as LessonTypeAbbrev;
const classNo: string = class_.split(":")[2];

Expand Down Expand Up @@ -497,7 +498,7 @@ const generateColors = (moduleCodeLessonTypeList: string[]) => {
*/
export const getModuleColorWithShade = (
colorMap: (string | null)[],
moduleCodeLessonType: string
moduleCodeLessonType: string,
) => {
const index = colorMap.indexOf(moduleCodeLessonType);

Expand All @@ -508,7 +509,7 @@ export const getModuleColorWithShade = (

export const getModuleColor = (
colorMap: (string | null)[],
moduleCodeLessonType: string
moduleCodeLessonType: string,
) => {
const index = colorMap.indexOf(moduleCodeLessonType);
const color = COLOR_INDEX[index % COLOR_INDEX.length];
Expand Down
Loading