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
4 changes: 4 additions & 0 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,7 @@ html {
*::-webkit-scrollbar-corner {
background: transparent;
}

button {
cursor: pointer;
}
34 changes: 31 additions & 3 deletions src/components/cards/FacultySelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function SelectField({ label, value, options, onChange, renderOption }: SelectFi
type SubjectEntry = {
slot: string;
faculty: string;
venue?: string;
};

function generateCourseSlotsSingle({
Expand All @@ -107,9 +108,16 @@ function generateCourseSlotsSingle({
return [
{
slotName: selectedSlot,
slotFaculties: selectedFaculties.map(facultyName => ({
facultyName,
})),
slotFaculties: selectedFaculties.map(facultyName => {
// try to get venue for this faculty and slot from subjectData
const entry = subjectData.find(
(e: SubjectEntry) => e.faculty === facultyName && e.slot === selectedSlot
);
return {
facultyName,
...(entry && entry.venue ? { venue: entry.venue } : {}),
};
}),
},
];
}
Expand All @@ -131,6 +139,7 @@ function generateCourseSlotsSingle({
)
.map((entry: SubjectEntry) => ({
facultyName: entry.faculty,
...(entry.venue ? { venue: entry.venue } : {}),
})),
}));
}
Expand Down Expand Up @@ -181,6 +190,7 @@ function generateCourseSlotsLabOnly({
.filter(entry => entry.slot === slotName && selectedFaculties.includes(entry.faculty))
.map(entry => ({
facultyName: entry.faculty,
...(entry.venue ? { venue: entry.venue } : {}),
})),
}));
}
Expand Down Expand Up @@ -236,9 +246,27 @@ function generateCourseSlotsBoth({
)
.map(entry => entry.slot);

// try to find a venue for this faculty: prefer labData entry, otherwise try theory entry
let venue: string | undefined;
const labEntryForVenue = labData.find(
entry =>
entry.faculty === facultyName && entry.slot.startsWith('L') && isValidLabSlot(entry.slot)
);
if (labEntryForVenue && labEntryForVenue.venue) {
venue = labEntryForVenue.venue;
} else {
// try to find theory entry
const theoryEntries = data[selectedSchool][selectedDomain][selectedSubject];
const thEntry = theoryEntries.find(
(e: SubjectEntry) => e.faculty === facultyName && e.slot === selectedSlot
);
if (thEntry && thEntry.venue) venue = thEntry.venue;
}

return {
facultyName,
...(labSlots.length > 0 && { facultyLabSlot: labSlots.join(', ') }),
...(venue ? { venue } : {}),
};
});

Expand Down
Loading