From d716c7efd0d1d615e73885e1fd34d949481d7b2b Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Wed, 28 Jul 2021 16:36:52 +0200 Subject: [PATCH] add the backend to the register form --- src/store/modules/coaches/actions.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/store/modules/coaches/actions.js b/src/store/modules/coaches/actions.js index 5e507f1..14ef6b8 100644 --- a/src/store/modules/coaches/actions.js +++ b/src/store/modules/coaches/actions.js @@ -1,5 +1,8 @@ +import getAPI from '../../../scripts/axios-api'; + export default { - registerCoach(context, data) { + async registerCoach(context, data) { + const userId = context.rootGetters.userId; const coachData = { id: context.rootGetters.userId, firstName: data.first, @@ -8,6 +11,16 @@ export default { hourlyRate: data.rate, areas: data.areas }; - context.commit('registerCoach', coachData); + + try { + await getAPI.put(`coaches/${userId}.json`, coachData); + } catch (err) { + console.log(err.response.status); + } + + context.commit('registerCoach', { + ...coachData, + id: userId + }); } };