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

Transfer credits now add up to total credits on sidebar #746

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for adding this!


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).
Expand Down
17 changes: 15 additions & 2 deletions packages/frontend/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,13 @@ const Sidebar: React.FC<SidebarProps> = 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 (
<SidebarContainer
Expand Down Expand Up @@ -247,12 +253,19 @@ const Sidebar: React.FC<SidebarProps> = memo(

interface NoMajorSidebarProps {
selectedPlan: PlanModel<string>;
transferCourses: ScheduleCourse2<unknown>[];
}

export const NoMajorSidebar: React.FC<NoMajorSidebarProps> = ({
selectedPlan,
transferCourses,
}) => {
const creditsTaken = totalCreditsInSchedule(selectedPlan.schedule);
const transferCredits = transferCourses.reduce(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the regular sidebar (the one that is not "no major") already support adding transfer course credits? if not, we should abstract the logic and add to both locations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I believe lines 193 - 199 add to the creditsTaken variable for the normal sidebar.

(sum, course) => course.numCreditsMin + sum,
0
);
const creditsTaken =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move this logic calculating schedule + transfer courses into one function that returns a credit value?

totalCreditsInSchedule(selectedPlan.schedule) + transferCredits;
return (
<SidebarContainer
title="No Major"
Expand Down
8 changes: 7 additions & 1 deletion packages/frontend/pages/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,13 @@ const HomePage: NextPage = () => {
transferCourses={student.coursesTransfered || []}
/>
);
} else renderedSidebar = <NoMajorSidebar selectedPlan={selectedPlan} />;
} else
renderedSidebar = (
<NoMajorSidebar
selectedPlan={selectedPlan}
transferCourses={student.coursesTransfered || []}
/>
);
}

return (
Expand Down
Loading