From 6c7678cdf25e29dbdc3062c83eb09cf2e24b6cfd Mon Sep 17 00:00:00 2001 From: Dennis Wang <66754085+hellolol2016@users.noreply.github.com> Date: Fri, 13 Sep 2024 19:26:29 -0400 Subject: [PATCH 1/2] transfer credits now add up to total credits on sidebar --- README.md | 2 ++ .../frontend/components/Sidebar/Sidebar.tsx | 17 +++++++++++++++-- packages/frontend/pages/home.tsx | 8 +++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ea37e1e09..0810536e8 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ GraduateNU aims to empower Northeastern students to customize their plan of stud 5. Then run the new version of the application by running `yarn dev` at the root of the project. This starts up a NestJS server + a NextJS frontend + a Proxy. The proxy listens on port [3002](http://localhost:3002/), forwards /api requests to the NestJS server running on port 3001, and all other requests to the frontend running on port 3000. +5a. For Windows machines, run `yarn concurrently "yarn workspaces foreach --parallel --verbose --interlaced run dev" "yarn dev:proxy"` instead of `yarn dev` + 6. Visit [http://localhost:3002](http://localhost:3002/) to view the app. To run the two separately, visit the frontend and api packages(sub directories of the monorepo). diff --git a/packages/frontend/components/Sidebar/Sidebar.tsx b/packages/frontend/components/Sidebar/Sidebar.tsx index e3e519cc9..dc339102a 100644 --- a/packages/frontend/components/Sidebar/Sidebar.tsx +++ b/packages/frontend/components/Sidebar/Sidebar.tsx @@ -190,7 +190,13 @@ const Sidebar: React.FC = memo( concentrationValidationStatus = SidebarValidationStatus.Error; } - const creditsTaken = totalCreditsInSchedule(selectedPlan.schedule); + const transferCredits = transferCourses.reduce( + (sum, course) => course.numCreditsMin + sum, + 0 + ); + + const creditsTaken = + totalCreditsInSchedule(selectedPlan.schedule) + transferCredits; return ( = memo( interface NoMajorSidebarProps { selectedPlan: PlanModel; + transferCourses: ScheduleCourse2[]; } export const NoMajorSidebar: React.FC = ({ selectedPlan, + transferCourses, }) => { - const creditsTaken = totalCreditsInSchedule(selectedPlan.schedule); + const transferCredits = transferCourses.reduce( + (sum, course) => course.numCreditsMin + sum, + 0 + ); + const creditsTaken = + totalCreditsInSchedule(selectedPlan.schedule) + transferCredits; return ( { transferCourses={student.coursesTransfered || []} /> ); - } else renderedSidebar = ; + } else + renderedSidebar = ( + + ); } return ( From b00e5c853d925dd279f7508f3ee0d4701b960237 Mon Sep 17 00:00:00 2001 From: Dennis Wang <66754085+hellolol2016@users.noreply.github.com> Date: Sun, 22 Sep 2024 16:39:01 -0400 Subject: [PATCH 2/2] changed totalcreditsinschedule function to take in transfer credit courses and calculate everything transferred the calculation logic into the totalcreditsinschedule function --- .../frontend/components/Sidebar/Sidebar.tsx | 17 ++++++----------- packages/frontend/utils/plan/totalCredits.ts | 15 +++++++++++---- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/packages/frontend/components/Sidebar/Sidebar.tsx b/packages/frontend/components/Sidebar/Sidebar.tsx index dc339102a..ae32e7044 100644 --- a/packages/frontend/components/Sidebar/Sidebar.tsx +++ b/packages/frontend/components/Sidebar/Sidebar.tsx @@ -190,14 +190,11 @@ const Sidebar: React.FC = memo( concentrationValidationStatus = SidebarValidationStatus.Error; } - const transferCredits = transferCourses.reduce( - (sum, course) => course.numCreditsMin + sum, - 0 + const creditsTaken = totalCreditsInSchedule( + selectedPlan.schedule, + transferCourses ); - const creditsTaken = - totalCreditsInSchedule(selectedPlan.schedule) + transferCredits; - return ( = ({ selectedPlan, transferCourses, }) => { - const transferCredits = transferCourses.reduce( - (sum, course) => course.numCreditsMin + sum, - 0 + const creditsTaken = totalCreditsInSchedule( + selectedPlan.schedule, + transferCourses ); - const creditsTaken = - totalCreditsInSchedule(selectedPlan.schedule) + transferCredits; return ( ): number => { @@ -23,12 +28,14 @@ export const totalCreditsInYear = ( /** The credits for all courses in a schedule summed. */ export const totalCreditsInSchedule = ( - schedule: Schedule2 + schedule: Schedule2, + transfer: ScheduleCourse2[] ): number => { return ( - schedule.years.reduce( + (schedule.years.reduce( (totalCredits, year) => totalCreditsInYear(year) + totalCredits, 0 - ) ?? 0 + ) ?? 0) + + (transfer.reduce((sum, course) => course.numCreditsMin + sum, 0) ?? 0) ); };