From 4de15fb471917b7f927991ea4d8ede90015b0105 Mon Sep 17 00:00:00 2001 From: elizabeth-tang <43019442+elizabeth-tang@users.noreply.github.com> Date: Fri, 15 Mar 2024 20:49:35 -0400 Subject: [PATCH] fixed order by (#903) * fixed order by * delete console --- src/components/Requirements/MultiplePlansDropdown.vue | 1 + src/components/Requirements/RequirementSideBar.vue | 1 + src/global-firestore-data/user-semesters.ts | 1 + src/store.ts | 4 +++- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/Requirements/MultiplePlansDropdown.vue b/src/components/Requirements/MultiplePlansDropdown.vue index a3923270f..347ea0676 100644 --- a/src/components/Requirements/MultiplePlansDropdown.vue +++ b/src/components/Requirements/MultiplePlansDropdown.vue @@ -87,6 +87,7 @@ export default defineComponent({ 'setCurrentPlan', store.state.plans.find(p => p.name === plan) ); + store.commit('setOrderByNewest', store.state.orderByNewest); this.shown = !this.shown; } }, diff --git a/src/components/Requirements/RequirementSideBar.vue b/src/components/Requirements/RequirementSideBar.vue index 8e5187a66..ab86deabe 100644 --- a/src/components/Requirements/RequirementSideBar.vue +++ b/src/components/Requirements/RequirementSideBar.vue @@ -393,6 +393,7 @@ export default defineComponent({ 'setCurrentPlan', store.state.plans.find(plan => plan.name === name) ); + store.commit('setOrderByNewest', store.state.orderByNewest); this.confirmationText = `${oldname} has been renamed to ${name}!`; this.isConfirmationOpen = true; setTimeout(() => { diff --git a/src/global-firestore-data/user-semesters.ts b/src/global-firestore-data/user-semesters.ts index 98ede8ae5..f03e663ae 100644 --- a/src/global-firestore-data/user-semesters.ts +++ b/src/global-firestore-data/user-semesters.ts @@ -28,6 +28,7 @@ export const editPlans = async ( await updateDoc(doc(semestersCollection, store.state.currentFirebaseUser.email), { plans, }); + store.commit('setOrderByNewest', store.state.orderByNewest); }; /** * Sets whether semesters are ordered by newest/oldest diff --git a/src/store.ts b/src/store.ts index c07494b43..6a5dc8d26 100644 --- a/src/store.ts +++ b/src/store.ts @@ -177,7 +177,9 @@ const store: TypedVuexStore = new TypedVuexStore({ name: state.currentPlan.name, semesters: sortedSemesters(semesters, state.orderByNewest), }; - const editedPlans = state.plans.map(plan => (plan === state.currentPlan ? editedPlan : plan)); + const editedPlans = state.plans.map(plan => + plan.name === state.currentPlan.name ? editedPlan : plan + ); state.plans = editedPlans; state.currentPlan = editedPlan; },