Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Courses in sidebar will display a checkmark if they are present anywhere in the users plan #783

Merged
merged 4 commits into from
Dec 5, 2024
Merged
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
23 changes: 22 additions & 1 deletion packages/frontend/components/Sidebar/SectionRequirement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ interface SidebarRequirementProps {
requirement: Requirement2;
courseData: { [id: string]: ScheduleCourse2<null> };
dndIdPrefix: string;
coursesTaken: ScheduleCourse2<unknown>[];
}

const SectionRequirement: React.FC<SidebarRequirementProps> = ({
requirement,
courseData,
dndIdPrefix,
coursesTaken,
}) => {
const renderRequirement = () => {
switch (requirement.type) {
Expand All @@ -47,6 +49,21 @@ const SectionRequirement: React.FC<SidebarRequirementProps> = ({
}
};

const isCourseInPlan = (requirement: Requirement2): boolean => {
let isTrue = false;
if (coursesTaken) {
coursesTaken.forEach((course) => {
if (
requirement.type === "COURSE" &&
getCourseDisplayString(course) === getCourseDisplayString(requirement)
) {
isTrue = true;
}
});
}
return isTrue;
};

const renderXOM = (requirement: IXofManyCourse) => {
return (
<div>
Expand All @@ -57,6 +74,7 @@ const SectionRequirement: React.FC<SidebarRequirementProps> = ({
<SectionRequirement
requirement={course}
courseData={courseData}
coursesTaken={coursesTaken}
dndIdPrefix={dndIdPrefix + "-" + index}
key={index}
/>
Expand All @@ -75,6 +93,7 @@ const SectionRequirement: React.FC<SidebarRequirementProps> = ({
<SectionRequirement
requirement={course}
courseData={courseData}
coursesTaken={coursesTaken}
dndIdPrefix={dndIdPrefix + "-" + index}
key={index}
/>
Expand All @@ -93,6 +112,7 @@ const SectionRequirement: React.FC<SidebarRequirementProps> = ({
<SectionRequirement
requirement={course}
courseData={courseData}
coursesTaken={coursesTaken}
dndIdPrefix={dndIdPrefix + "-" + index}
key={index}
/>
Expand Down Expand Up @@ -130,7 +150,7 @@ const SectionRequirement: React.FC<SidebarRequirementProps> = ({
}}
isInSidebar
// TODO: isChecked is for when the requirement is added to the plan and validated. When true, this will render a checkmark.
isChecked={false}
isChecked={isCourseInPlan(requirement)}
isDisabled={false}
/>
);
Expand All @@ -145,6 +165,7 @@ const SectionRequirement: React.FC<SidebarRequirementProps> = ({
validationStatus={SidebarValidationStatus.Complete}
section={requirement}
courseData={courseData}
coursesTaken={coursesTaken}
dndIdPrefix={dndIdPrefix + "-sec"}
/>
);
Expand Down
2 changes: 2 additions & 0 deletions packages/frontend/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ const Sidebar: React.FC<SidebarProps> = memo(
courseData={courseData}
dndIdPrefix={`${SIDEBAR_DND_ID_PREFIX}-${index}`}
loading={isCoursesLoading}
coursesTaken={coursesTaken}
/>
);
})}
Expand All @@ -267,6 +268,7 @@ const Sidebar: React.FC<SidebarProps> = memo(
section={concentration}
courseData={courseData}
dndIdPrefix={`${SIDEBAR_DND_ID_PREFIX}-concentration`}
coursesTaken={[]}
/>
)}
</>
Expand Down
3 changes: 3 additions & 0 deletions packages/frontend/components/Sidebar/SidebarSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface SidebarSectionProps {
courseData: { [id: string]: ScheduleCourse2<null> };
dndIdPrefix: string;
validationStatus: SidebarValidationStatus;
coursesTaken: ScheduleCourse2<unknown>[];
loading?: boolean;
}

Expand All @@ -27,6 +28,7 @@ const SidebarSection: React.FC<SidebarSectionProps> = ({
dndIdPrefix,
validationStatus,
loading,
coursesTaken,
}) => {
const [opened, setOpened] = useState(false);

Expand Down Expand Up @@ -201,6 +203,7 @@ const SidebarSection: React.FC<SidebarSectionProps> = ({
courseData={courseData}
dndIdPrefix={dndIdPrefix + "-" + index}
key={index}
coursesTaken={coursesTaken}
/>
))}
</>
Expand Down
Loading