diff --git a/packages/api/src/plan/plan.service.ts b/packages/api/src/plan/plan.service.ts index f8a902b2..df40dc06 100644 --- a/packages/api/src/plan/plan.service.ts +++ b/packages/api/src/plan/plan.service.ts @@ -122,6 +122,7 @@ export class PlanService { ): Promise { const { major: newMajorName, + minor: newMinorName, catalogYear: newCatalogYear, concentration: newConcentrationName, schedule: newSchedule, @@ -156,6 +157,10 @@ export class PlanService { !newConcentrationName && currentPlan.major; + /** Wipe Minor => Remove existing minor from the plan. */ + const isWipeMinorUpdate = + !newMinorName && !newCatalogYear && currentPlan.minor; + const isScheduleUpdate = newSchedule && !isMajorInfoUpdate; if ( @@ -241,6 +246,7 @@ export class PlanService { let name = currentPlan.name; let schedule = currentPlan.schedule; let major = isWipeMajorUpdate ? undefined : currentPlan.major; + let minor = isWipeMinorUpdate ? undefined : currentPlan.minor; let catalogYear = isWipeMajorUpdate ? undefined : currentPlan.catalogYear; let concentration = isWipeMajorUpdate ? undefined @@ -260,9 +266,14 @@ export class PlanService { concentration = newConcentrationName; } + if (newMinorName) { + minor = newMinorName; + } + const newPlan = { name, major, + minor, catalogYear, concentration, schedule, diff --git a/packages/frontend/components/Plan/EditPlanModal.tsx b/packages/frontend/components/Plan/EditPlanModal.tsx index 5d41601c..9214f1d6 100644 --- a/packages/frontend/components/Plan/EditPlanModal.tsx +++ b/packages/frontend/components/Plan/EditPlanModal.tsx @@ -187,6 +187,7 @@ export const EditPlanModal: React.FC = ({ plan }) => { ); } else { try { + console.log("Updating plan", plan.id, newPlan); await API.plans.update(plan.id, newPlan); } catch (error) { handleApiClientError(error as Error, router); diff --git a/packages/frontend/hooks/useMinor.ts b/packages/frontend/hooks/useMinor.ts index dfb27f2f..c00e5e80 100644 --- a/packages/frontend/hooks/useMinor.ts +++ b/packages/frontend/hooks/useMinor.ts @@ -20,8 +20,6 @@ type MinorReturn = MinorResponse & { * @param minorName The name of the major, ex: "Computer Science, BSCS". */ export function useMinor(catalogYear: number, minorName: string): MinorReturn { - console.log("useMinor called with: ", catalogYear, minorName); - // debugger; const key = `api/minor/${catalogYear}/${minorName}`; const { data, ...rest } = useSWR( diff --git a/packages/frontend/utils/plan/getAllCoursesInMajor.ts b/packages/frontend/utils/plan/getAllCoursesInMajor.ts index a3b659db..a6000f0e 100644 --- a/packages/frontend/utils/plan/getAllCoursesInMajor.ts +++ b/packages/frontend/utils/plan/getAllCoursesInMajor.ts @@ -16,8 +16,8 @@ export const getAllCoursesInMinor = ( const minorRequirements = minor.requirementSections.reduce( (courses: IRequiredCourse[], section: Section) => { const requiredCourses: IRequiredCourse[] = []; - console.log("section requirements for minor"); - console.log(section.requirements); + // console.log("section requirements for minor"); + // console.log(section.requirements); // if (section.requirements) { // getRequiredCourses(section.requirements, requiredCourses); // }