diff --git a/components/CourseList.vue b/components/CourseList.vue
new file mode 100644
index 0000000..a78eecf
--- /dev/null
+++ b/components/CourseList.vue
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+ {{ id.toUpperCase() }}
+ {{ course.name }}
+
+
+
+ {{ isFavoriteCourse(id) ? 'mdi-heart' : 'mdi-heart-outline' }}
+
+
+
+
+
+
+
+
+
diff --git a/pages/dashboard.vue b/pages/dashboard.vue
index 8bd4717..aa2a3da 100644
--- a/pages/dashboard.vue
+++ b/pages/dashboard.vue
@@ -1,26 +1,31 @@
-
+
+
+
+
+
+
-
-
+
+
+ Meine Kurse ({{ Object.keys(userCourses).length }})
+ Alle Kurse ({{ Object.keys(allCourses).length }})
+
-
-
-
-
-
-
-
- {{ id.toUpperCase() }}
- {{ course.name }}
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -29,6 +34,7 @@
diff --git a/plugins/user.js b/plugins/user.js
index d56f8b9..491a1e8 100644
--- a/plugins/user.js
+++ b/plugins/user.js
@@ -1,6 +1,7 @@
export class User {
- constructor (displayName, gamesStarted) {
+ constructor (displayName, courses, gamesStarted) {
this.displayName = displayName
+ this.courses = courses
this.gamesStarted = []
if (gamesStarted && gamesStarted.length > 0) {
@@ -21,11 +22,12 @@ export const UserConverter = {
return {
anzeigename: user.displayName,
+ kurse: user.courses,
spieleBegonnen
}
},
fromFirestore: (snapshot, options) => {
const data = snapshot.data(options)
- return new User(data.anzeigename, data.spieleBegonnen)
+ return new User(data.anzeigename, data.kurse, data.spieleBegonnen)
}
}
\ No newline at end of file
diff --git a/store/index.js b/store/index.js
index ec3df28..622675e 100644
--- a/store/index.js
+++ b/store/index.js
@@ -1,3 +1,5 @@
+import _pick from 'lodash-es/pick'
+
export const state = () => ({
firebaseInitialized: false,
idTokenResult: null,
@@ -12,6 +14,10 @@ export const getters = {
},
getCourseByID: (state) => (courseID) => {
return state.courses[courseID]
+ },
+ getFavoriteCourses (state) {
+ // Ref: https://lodash.com/docs/#pick
+ return _pick(state.courses, state.user.courses)
}
}
@@ -31,6 +37,13 @@ export const mutations = {
setCourses (state, courses) {
state.courses = courses
},
+ addFavoriteCourse (state, courseID) {
+ state.user.courses.push(courseID)
+ },
+ removeFavoriteCourse (state, courseID) {
+ const index = state.user.courses.findIndex(e => e === courseID)
+ state.user.courses.splice(index, 1)
+ },
setCourse (state, { courseID, courseData }) {
this._vm.$set(state.courses, courseID, courseData)
},