From f08cdf04b9b834b238811e617bb52732c01577fa Mon Sep 17 00:00:00 2001 From: Jake Langlois Date: Sun, 24 Nov 2024 17:19:36 -0500 Subject: [PATCH 1/4] adjust sectionRequirements props to take all the courses from the plan and check if a course in the sidebar needs a checkmark --- .../components/Sidebar/SectionRequirement.tsx | 26 ++++++++++++++++++- .../frontend/components/Sidebar/Sidebar.tsx | 2 ++ .../components/Sidebar/SidebarSection.tsx | 3 +++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/frontend/components/Sidebar/SectionRequirement.tsx b/packages/frontend/components/Sidebar/SectionRequirement.tsx index bdb0f354e..6663c9528 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,24 @@ const SectionRequirement: React.FC = ({ } }; + const isCourseInPlan = (requirement: Requirement2): boolean => { + let isTrue = false; + console.log(requirement, " AsdASDASJKDas"); + if (coursesTaken) { + coursesTaken.forEach((course) => { + if ( + requirement.type === "COURSE" && + course.classId === requirement.classId.toString() + ) { + console.log("This is true"); + isTrue = true; + } + }); + } + console.log(isTrue, " is the"); + return isTrue; + }; + const renderXOM = (requirement: IXofManyCourse) => { return (
@@ -57,6 +77,7 @@ const SectionRequirement: React.FC = ({ @@ -75,6 +96,7 @@ const SectionRequirement: React.FC = ({ @@ -93,6 +115,7 @@ const SectionRequirement: React.FC = ({ @@ -130,7 +153,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 +168,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 60a642cf1..dd3f449d4 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 9ad5442f9..727dca2a5 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} /> ))} From 3d8f115bc54231cfeff8fc3640b74fbe65412c7e Mon Sep 17 00:00:00 2001 From: Jake Langlois Date: Mon, 25 Nov 2024 11:54:59 -0500 Subject: [PATCH 2/4] unused --- packages/frontend/components/Sidebar/SectionRequirement.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/frontend/components/Sidebar/SectionRequirement.tsx b/packages/frontend/components/Sidebar/SectionRequirement.tsx index 6663c9528..ff71fd6ce 100644 --- a/packages/frontend/components/Sidebar/SectionRequirement.tsx +++ b/packages/frontend/components/Sidebar/SectionRequirement.tsx @@ -51,7 +51,6 @@ const SectionRequirement: React.FC = ({ const isCourseInPlan = (requirement: Requirement2): boolean => { let isTrue = false; - console.log(requirement, " AsdASDASJKDas"); if (coursesTaken) { coursesTaken.forEach((course) => { if ( From b3d2a1f077de529bce08f68a13330a5865f8167f Mon Sep 17 00:00:00 2001 From: Jake Langlois Date: Tue, 3 Dec 2024 20:02:09 -0500 Subject: [PATCH 3/4] make sure course subject is checked when validating a completed course in sidebar --- packages/frontend/components/Sidebar/SectionRequirement.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/frontend/components/Sidebar/SectionRequirement.tsx b/packages/frontend/components/Sidebar/SectionRequirement.tsx index ff71fd6ce..b7976077c 100644 --- a/packages/frontend/components/Sidebar/SectionRequirement.tsx +++ b/packages/frontend/components/Sidebar/SectionRequirement.tsx @@ -55,9 +55,9 @@ const SectionRequirement: React.FC = ({ coursesTaken.forEach((course) => { if ( requirement.type === "COURSE" && - course.classId === requirement.classId.toString() + course.classId === requirement.classId.toString() && + course.subject === requirement.subject ) { - console.log("This is true"); isTrue = true; } }); From b8d6a344d090d725094d285685322dfac0e99c98 Mon Sep 17 00:00:00 2001 From: Jake Langlois Date: Tue, 3 Dec 2024 21:26:46 -0500 Subject: [PATCH 4/4] cleaning --- packages/frontend/components/Sidebar/SectionRequirement.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/frontend/components/Sidebar/SectionRequirement.tsx b/packages/frontend/components/Sidebar/SectionRequirement.tsx index b7976077c..45b56e3f5 100644 --- a/packages/frontend/components/Sidebar/SectionRequirement.tsx +++ b/packages/frontend/components/Sidebar/SectionRequirement.tsx @@ -55,14 +55,12 @@ const SectionRequirement: React.FC = ({ coursesTaken.forEach((course) => { if ( requirement.type === "COURSE" && - course.classId === requirement.classId.toString() && - course.subject === requirement.subject + getCourseDisplayString(course) === getCourseDisplayString(requirement) ) { isTrue = true; } }); } - console.log(isTrue, " is the"); return isTrue; };