Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into ui-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelaZQ1 committed Oct 22, 2023
2 parents c608ebf + e377149 commit 6eb83c0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"lint": "eslint packages/ --ext .ts,.tsx .",
"tsc": "yarn workspaces foreach -v --exclude . run tsc",
"g:babel": "cd $INIT_CWD && babel",
"g:cross-env": "cd $INIT_CWD && cross-env"
"g:cross-env": "cd $INIT_CWD && cross-env",
"postinstall": "husky install"
},
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.18.6",
Expand Down
8 changes: 6 additions & 2 deletions packages/frontend-v2/pages/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ const HomePage: NextPage = () => {
if (student) {
const plan = student.plans.find((plan) => plan.id === selectedPlanId);
if (plan) {
setPreReqWarnings(getPreReqWarnings(plan.schedule));
setPreReqWarnings(
getPreReqWarnings(plan.schedule, student.coursesTransfered)
);
setCoReqWarnings(getCoReqWarnings(plan.schedule));
}
}
Expand Down Expand Up @@ -170,7 +172,9 @@ const HomePage: NextPage = () => {
return;
}

setPreReqWarnings(getPreReqWarnings(updatedPlan.schedule));
setPreReqWarnings(
getPreReqWarnings(updatedPlan.schedule, student.coursesTransfered)
);
setCoReqWarnings(getCoReqWarnings(updatedPlan.schedule));
mutateStudentWithUpdatedPlan(updatedPlan);
};
Expand Down
17 changes: 11 additions & 6 deletions packages/frontend-v2/utils/plan/preAndCoReqCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
INEUReqError,
PreReqWarnings,
Schedule2,
ScheduleCourse2,
ScheduleTerm2,
TermError,
} from "@graduate/common";
Expand Down Expand Up @@ -44,9 +45,15 @@ export const getCoReqWarningsSem = (
};

export const getPreReqWarnings = (
schedule: Schedule2<unknown>
schedule: Schedule2<unknown>,
coursesTransfered: ScheduleCourse2<null>[] | undefined
): PreReqWarnings => {
const seen: Set<string> = new Set();
if (coursesTransfered != undefined) {
for (const course of coursesTransfered) {
seen.add(courseToString(course));
}
}
const preReqErrors: PreReqWarnings = {
type: "prereq",
years: schedule.years.map((year) => ({
Expand All @@ -55,8 +62,8 @@ export const getPreReqWarnings = (
spring: getPreReqWarningSem(year.spring, seen),
summer1: getPreReqWarningSem(year.summer1, seen),
summer2: getPreReqWarningSem(year.summer2, seen),
}))
}
})),
};
return preReqErrors;
};

Expand Down Expand Up @@ -128,8 +135,6 @@ const isOrCourse = (course: INEUReq): course is INEUOrReq => {
return (course as INEUOrReq).type === "or";
};

const isError = (
error: INEUReqError | undefined
): error is INEUReqError => {
const isError = (error: INEUReqError | undefined): error is INEUReqError => {
return !!error;
};

0 comments on commit 6eb83c0

Please sign in to comment.