diff --git a/src/components/AdditionalSubjectsDropDown.vue b/src/components/AdditionalSubjectsDropDown.vue
index a5d635b4..1bf78eab 100644
--- a/src/components/AdditionalSubjectsDropDown.vue
+++ b/src/components/AdditionalSubjectsDropDown.vue
@@ -84,8 +84,9 @@ export default {
methods: {
isComplete(includedSubjects) {
+ // Check if the user has all required certifications for the subject
return includedSubjects.every(subject =>
- this.user.subjects.includes(subject.key)
+ this.user.subjects.some(s => s.subject === subject.key)
);
},
progressStatus(includedSubjects) {
diff --git a/src/components/SubjectCertsDropDown.vue b/src/components/SubjectCertsDropDown.vue
index 295e0738..2eb8cb43 100644
--- a/src/components/SubjectCertsDropDown.vue
+++ b/src/components/SubjectCertsDropDown.vue
@@ -118,8 +118,9 @@ export default {
return this.user.certifications[cert].passed;
},
hasUnlockedSubject(cert) {
- if (cert === "algebra") return this.user.subjects.includes("algebraOne");
- return this.user.subjects.includes(cert);
+ if (cert === "algebra")
+ return this.user.subjects.some(s => s.subject === "algebraOne");
+ return this.user.subjects.some(s => s.subject === cert);
},
progressStatus(cert) {
if (this.isComplete(cert)) return "Completed";
diff --git a/src/views/DashboardView/VolunteerDashboard/ListSessions.vue b/src/views/DashboardView/VolunteerDashboard/ListSessions.vue
index 57cccf4d..2dc348a5 100644
--- a/src/views/DashboardView/VolunteerDashboard/ListSessions.vue
+++ b/src/views/DashboardView/VolunteerDashboard/ListSessions.vue
@@ -132,7 +132,9 @@ export default {
if (
Object.keys(allSubtopics()).some(
- s => s === subTopic && this.user.subjects.includes(s)
+ s =>
+ s === subTopic &&
+ this.user.subjects.some(({ subject }) => subject === s)
)
) {
results.push(session);
diff --git a/src/views/ProfileView.vue b/src/views/ProfileView.vue
index 30022867..1be078c8 100644
--- a/src/views/ProfileView.vue
+++ b/src/views/ProfileView.vue
@@ -103,14 +103,35 @@
-
-
- {{ certKey[key] }}
+
+
+
+ {{ certKey[subject].subjectType }}
+
+ {{
+ certKey[subject].displayName
+ }}
-
{{ key }}
+
toggleSubjectActivated(event, subject)"
+ :sync="true"
+ />
@@ -123,7 +144,7 @@
import PhoneNumber from "awesome-phonenumber";
import { mapGetters, mapState } from "vuex";
import UserService from "@/services/UserService";
-import { topics, allSubtopics } from "@/utils/topics";
+import { topics } from "@/utils/topics";
import DeactivateAccountModal from "./DeactivateAccountModal";
export default {
@@ -141,10 +162,12 @@ export default {
phoneNational: "",
phoneInputInfo: {},
isAccountActive: true,
- showDeactivateAccountModal: false
+ showDeactivateAccountModal: false,
+ modifiedSubjects: []
};
},
created() {
+ this.modifiedSubjects = this.user.subjects;
this.isAccountActive = !this.user.isDeactivated;
if (this.user.isVolunteer && this.user.phone) {
const num =
@@ -189,26 +212,14 @@ export default {
for (let topic in topicData.subtopics) {
if (topicData.subtopics.hasOwnProperty(topic)) {
const { displayName } = topicData.subtopics[topic];
- subtopicObj[displayName] = topicName.toUpperCase();
+ subtopicObj[topic] = {
+ subjectType: topicName.toUpperCase(),
+ displayName
+ };
}
}
}
return subtopicObj;
- },
- subjects() {
- const user = this.$store.state.user.user;
-
- const subjects = user.subjects.reduce((displayObj, key) => {
- const subtopics = allSubtopics();
-
- if (subtopics[key]) {
- displayObj[subtopics[key].displayName || subtopics[key]] = true;
- }
-
- return displayObj;
- }, {});
-
- return subjects;
}
},
methods: {
@@ -268,11 +279,10 @@ export default {
if (!this.errors.length) {
// form fields valid, so set profile
this.user.phone = this.phoneInputInfo.e164;
- this.user.isDeactivated = !this.isAccountActive;
-
+ this.user.subjects = this.modifiedSubjects;
// send only the necessary data
const payloadUser = {};
- const keys = ["phone", "isDeactivated"];
+ const keys = ["phone", "isDeactivated", "subjects"];
keys.forEach(key => (payloadUser[key] = this.user[key]));
@@ -288,6 +298,11 @@ export default {
}
);
}
+ },
+ toggleSubjectActivated({ value }, subject) {
+ for (const s of this.modifiedSubjects) {
+ if (s.subject === subject) s.isActivated = value;
+ }
}
}
};
@@ -485,10 +500,9 @@ button:hover {
}
.certBox {
- display: flex;
+ @include flex-container(row, space-between, center);
height: 60px;
- align-items: center;
- padding-left: 20px;
+ padding: 0 20px;
border-top: 1px solid #cccccf;
font-weight: 600;
}