diff --git a/packages/frontend/components/Sidebar/SectionRequirement.tsx b/packages/frontend/components/Sidebar/SectionRequirement.tsx index bdb0f354..45b56e3f 100644 --- a/packages/frontend/components/Sidebar/SectionRequirement.tsx +++ b/packages/frontend/components/Sidebar/SectionRequirement.tsx @@ -21,12 +21,14 @@ interface SidebarRequirementProps { requirement: Requirement2; courseData: { [id: string]: ScheduleCourse2 }; dndIdPrefix: string; + coursesTaken: ScheduleCourse2[]; } const SectionRequirement: React.FC = ({ requirement, courseData, dndIdPrefix, + coursesTaken, }) => { const renderRequirement = () => { switch (requirement.type) { @@ -47,6 +49,21 @@ const SectionRequirement: React.FC = ({ } }; + 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 (
@@ -57,6 +74,7 @@ const SectionRequirement: React.FC = ({ @@ -75,6 +93,7 @@ const SectionRequirement: React.FC = ({ @@ -93,6 +112,7 @@ const SectionRequirement: React.FC = ({ @@ -130,7 +150,7 @@ const SectionRequirement: React.FC = ({ }} 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} /> ); @@ -145,6 +165,7 @@ const SectionRequirement: React.FC = ({ validationStatus={SidebarValidationStatus.Complete} section={requirement} courseData={courseData} + coursesTaken={coursesTaken} dndIdPrefix={dndIdPrefix + "-sec"} /> ); diff --git a/packages/frontend/components/Sidebar/Sidebar.tsx b/packages/frontend/components/Sidebar/Sidebar.tsx index 60a642cf..dd3f449d 100644 --- a/packages/frontend/components/Sidebar/Sidebar.tsx +++ b/packages/frontend/components/Sidebar/Sidebar.tsx @@ -258,6 +258,7 @@ const Sidebar: React.FC = memo( courseData={courseData} dndIdPrefix={`${SIDEBAR_DND_ID_PREFIX}-${index}`} loading={isCoursesLoading} + coursesTaken={coursesTaken} /> ); })} @@ -267,6 +268,7 @@ const Sidebar: React.FC = memo( section={concentration} courseData={courseData} dndIdPrefix={`${SIDEBAR_DND_ID_PREFIX}-concentration`} + coursesTaken={[]} /> )} diff --git a/packages/frontend/components/Sidebar/SidebarSection.tsx b/packages/frontend/components/Sidebar/SidebarSection.tsx index 9ad5442f..727dca2a 100644 --- a/packages/frontend/components/Sidebar/SidebarSection.tsx +++ b/packages/frontend/components/Sidebar/SidebarSection.tsx @@ -18,6 +18,7 @@ interface SidebarSectionProps { courseData: { [id: string]: ScheduleCourse2 }; dndIdPrefix: string; validationStatus: SidebarValidationStatus; + coursesTaken: ScheduleCourse2[]; loading?: boolean; } @@ -27,6 +28,7 @@ const SidebarSection: React.FC = ({ dndIdPrefix, validationStatus, loading, + coursesTaken, }) => { const [opened, setOpened] = useState(false); @@ -201,6 +203,7 @@ const SidebarSection: React.FC = ({ courseData={courseData} dndIdPrefix={dndIdPrefix + "-" + index} key={index} + coursesTaken={coursesTaken} /> ))}