From 601ccd9ef427f406b3eab6251b8b3f99e0b401c1 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 3 Jun 2021 14:49:09 +0200 Subject: [PATCH] user data can be updated in DB --- frontend/src/apis/loginAPI.js | 6 +-- frontend/src/store/store.js | 19 +++++-- .../UserProfile/UserCard_FormUserData.vue | 50 ++++++++++--------- .../src/views/Pages/UserProfileOverview.vue | 42 +--------------- 4 files changed, 46 insertions(+), 71 deletions(-) diff --git a/frontend/src/apis/loginAPI.js b/frontend/src/apis/loginAPI.js index 5f4e72807..850a3a44d 100644 --- a/frontend/src/apis/loginAPI.js +++ b/frontend/src/apis/loginAPI.js @@ -86,13 +86,13 @@ const loginAPI = { } return apiPost(CONFIG.LOGIN_API_URL + 'getUserInfos', payload) }, - updateUserInfos: async (sessionId, email, firstName, lastName /*, description */) => { + updateUserInfos: async (sessionId, email, data) => { const payload = { session_id: sessionId, email, update: { - 'User.first_name': firstName, - 'User.last_name': lastName, + 'User.first_name': data.firstName, + 'User.last_name': data.lastName, /* 'User.description': description, */ }, } diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js index 79f04da61..02e8f0561 100644 --- a/frontend/src/store/store.js +++ b/frontend/src/store/store.js @@ -14,9 +14,14 @@ export const mutations = { state.sessionId = sessionId }, username: (state, username) => { - // console.log('store username mutation', username) state.username = username }, + firstName: (state, firstName) => { + state.firstName = firstName + }, + lastName: (state, lastName) => { + state.lastName = lastName + }, } export const actions = { @@ -24,12 +29,16 @@ export const actions = { commit('sessionId', data.sessionId) commit('email', data.user.email) commit('language', data.user.language) - commit('username', data.user.username ? '' : 'teststoreusername') + commit('username', data.user.username) + commit('firstName', data.user.first_name) + commit('lastName', data.user.last_name) }, logout: ({ commit, state }) => { commit('sessionId', null) commit('email', null) - commit('username', null) + commit('username', '') + commit('firstName', '') + commit('lastName', '') sessionStorage.clear() }, } @@ -45,7 +54,9 @@ export const store = new Vuex.Store({ email: '', language: null, modals: false, - username: 'testname', + firstName: '', + lastName: '', + username: '', }, getters: {}, // Syncronous mutation of the state diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue index 87490dfab..e89a17e84 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue @@ -3,14 +3,14 @@ - + {{ $t('form.edit') }}
{{ $t('form.save') }} - + {{ $t('form.cancel') }} @@ -24,8 +24,8 @@ {{ $t('form.firstname') }} - - {{ userdata.first_name }} + + {{ form.firstName }} @@ -35,8 +35,8 @@ {{ $t('form.lastname') }} - - {{ userdata.last_name }} + + {{ form.lastName }} @@ -46,7 +46,7 @@ {{ $t('form.description') }} - + {{ UserProfileTestData.desc }} @@ -58,37 +58,41 @@