From abf6109d91eda627deda1326eb103f76975ff7f0 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Tue, 29 Jun 2021 21:55:19 +0200 Subject: [PATCH] store registered coaches in the store --- src/pages/coaches/CoachRegistration.vue | 9 +++++++-- src/store/modules/coaches/actions.js | 14 +++++++++++++- src/store/modules/coaches/mutations.js | 6 +++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/pages/coaches/CoachRegistration.vue b/src/pages/coaches/CoachRegistration.vue index 9b88ef4..3f0575c 100644 --- a/src/pages/coaches/CoachRegistration.vue +++ b/src/pages/coaches/CoachRegistration.vue @@ -2,7 +2,7 @@

Register as a coach, now!

- +
@@ -10,6 +10,11 @@ import CoachForm from '../../components/coaches/CoachForm.vue'; export default { - components: { CoachForm } + components: { CoachForm }, + methods: { + saveData(data) { + this.$store.dispatch('coaches/registerCoach', data); + } + } }; diff --git a/src/store/modules/coaches/actions.js b/src/store/modules/coaches/actions.js index ff8b4c5..7fc01af 100644 --- a/src/store/modules/coaches/actions.js +++ b/src/store/modules/coaches/actions.js @@ -1 +1,13 @@ -export default {}; +export default { + registerCoach(context, data) { + const coachData = { + id: new Date().toISOString(), + firstName: data.first, + lastName: data.last, + description: data.desc, + rate: data.rate, + areas: data.areas + }; + context.commit('registerCoach', coachData); + } +}; diff --git a/src/store/modules/coaches/mutations.js b/src/store/modules/coaches/mutations.js index ff8b4c5..979cd80 100644 --- a/src/store/modules/coaches/mutations.js +++ b/src/store/modules/coaches/mutations.js @@ -1 +1,5 @@ -export default {}; +export default { + registerCoach(state, payload) { + state.coaches.push(payload); + } +};