Skip to content

Commit

Permalink
Display "No Courses Added Yet" when list of added classes is empty (#924
Browse files Browse the repository at this point in the history
)

Co-authored-by: Kevin Wu <[email protected]>
  • Loading branch information
ollykel and KevinWu098 authored Feb 29, 2024
1 parent d219cf9 commit baa02f9
Showing 1 changed file with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,14 @@ function SkeletonSchedule() {
}, []);

const sectionsByTerm: [string, string[]][] = useMemo(() => {
const result = skeletonSchedule.courses.reduce((accumulated, course) => {
accumulated[course.term] ??= [];
accumulated[course.term].push(course.sectionCode);
return accumulated;
}, {} as Record<string, string[]>);
const result = skeletonSchedule.courses.reduce(
(accumulated, course) => {
accumulated[course.term] ??= [];
accumulated[course.term].push(course.sectionCode);
return accumulated;
},
{} as Record<string, string[]>
);

return Object.entries(result);
}, [skeletonSchedule.courses]);
Expand Down Expand Up @@ -403,6 +406,13 @@ function AddedSectionsGrid() {
return scheduleNames[scheduleIndex];
}, [scheduleNames, scheduleIndex]);

// "No Courses Added Yet!" notification
const NoCoursesBox = (
<Box style={{ paddingTop: '12px', paddingBottom: '12px' }}>
<Typography align="left">No Courses Added Yet!</Typography>
</Box>
);

return (
<Box display="flex" flexDirection="column" gap={1}>
<Box display="flex" width={1} position="absolute" zIndex="2">
Expand All @@ -412,6 +422,7 @@ function AddedSectionsGrid() {
</Box>
<Box style={{ marginTop: 50 }}>
<Typography variant="h6">{`${scheduleName} (${scheduleUnits} Units)`}</Typography>
{courses.length < 1 ? NoCoursesBox : null}
<Box display="flex" flexDirection="column" gap={1}>
{courses.map((course) => {
return (
Expand Down

0 comments on commit baa02f9

Please sign in to comment.