diff --git a/frontend/src/apis/loginAPI.js b/frontend/src/apis/loginAPI.js index 55e32e6dd..91e92a2cc 100644 --- a/frontend/src/apis/loginAPI.js +++ b/frontend/src/apis/loginAPI.js @@ -78,6 +78,27 @@ const loginAPI = { CONFIG.LOGIN_API_URL + 'loginViaEmailVerificationCode?emailVerificationCode=' + optin, ) }, + getUserInfos: async (sessionId, email) => { + const payload = { + session_id: sessionId, + email: email, + ask: ['user.first_name', 'user.last_name'], + } + return apiPost(CONFIG.LOGIN_API_URL + 'getUserInfos', payload) + }, + updateUserInfos: async (sessionId, email, data) => { + const payload = { + session_id: sessionId, + email, + update: { + 'User.first_name': data.firstName, + 'User.last_name': data.lastName, + 'User.description': data.description, + }, + } + return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload) + }, + changePassword: async (sessionId, email, password) => { const payload = { session_id: sessionId, @@ -88,6 +109,27 @@ const loginAPI = { } return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload) }, + changePasswordProfile: async (sessionId, email, password, passwordNew) => { + const payload = { + session_id: sessionId, + email, + update: { + 'User.password': password, + 'User.passwordNew': passwordNew, + }, + } + return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload) + }, + changeUsernameProfile: async (sessionId, email, usernameNew) => { + const payload = { + session_id: sessionId, + email, + update: { + 'User.usernameNew': usernameNew, + }, + } + return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload) + }, updateLanguage: async (sessionId, email, language) => { const payload = { session_id: sessionId, diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 81fb90972..5a499b7f4 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -20,17 +20,25 @@ }, "decay": "Vergänglichkeit", "form": { - "cancel":"Abbrechen", + "cancel": "Abbrechen", "reset": "Zurücksetzen", - "close":"schließen", + "close": "schließen", + "edit": "bearbeiten", + "save": "speichern", "receiver":"Empfänger", "sender":"Absender", + "username":"Username", "firstname":"Vorname", "lastname":"Nachname", + "description": "Beschreibung", "email":"E-Mail", "email_repeat":"eMail wiederholen", "password":"Passwort", "password_repeat":"Passwort wiederholen", + "password_old":"altes Passwort", + "password_new":"neues Passwort", + "password_new_repeat":"neues Passwort wiederholen", + "change": "ändern", "amount":"Betrag", "memo":"Nachricht für den Empfänger", "message":"Nachricht", @@ -49,8 +57,9 @@ "send_transaction_error":"Leider konnte die Transaktion nicht ausgeführt werden!", "validation": { "double": "Das Feld {field} muss eine Dezimalzahl mit zwei Nachkommastellen sein", - "is-not": "Du kannst dir selbst keine Gradidos überweisen" - } + "is-not": "Du kannst Dir selbst keine Gradidos überweisen" + }, + "change_username_info": "Das ändern des Usernamens bedarf mehrerer Schritte." }, "error": { "error":"Fehler" @@ -96,7 +105,6 @@ "add_work":"neuer Gemeinschaftsbeitrag" }, "profil": { - "transactions":"transactions", "activity": { "chart":"Gemeinschaftsstunden Chart", "new":"Neue Gemeinschaftsstunden eintragen", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 58ebbf9f1..aa42d966e 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -1,7 +1,7 @@ { "message": "hello gradido !!", "welcome":"Welcome!", - "community": "Gemeinschaft", + "community": "Community", "logout":"Logout", "login":"Login", "signup": "Sign up", @@ -23,14 +23,22 @@ "cancel":"Cancel", "reset": "Reset", "close":"Close", + "edit": "Edit", + "save": "save", "receiver":"Receiver", "sender":"Sender", + "username":"Username", "firstname":"Firstname", "lastname":"Lastname", + "description": "Description", "email":"Email", "email_repeat":"Repeat Email", "password":"Password", "password_repeat":"Repeat password", + "password_old":"Old password", + "password_new":"New password", + "password_new_repeat":"Repeat new password", + "change": "change", "amount":"Amount", "memo":"Message for the recipient", "message":"Message", @@ -50,7 +58,8 @@ "validation": { "double": "The {field} field must be a decimal with two digits", "is-not": "You cannot send Gradidos to yourself" - } + }, + "change_username_info": "Changing the username requires several steps." }, "error": { "error":"Error" diff --git a/frontend/src/routes/routes.js b/frontend/src/routes/routes.js index 16ab3d78f..44ef1f27a 100755 --- a/frontend/src/routes/routes.js +++ b/frontend/src/routes/routes.js @@ -16,25 +16,11 @@ const routes = [ }, { path: '/profile', - component: () => import('../views/Pages/UserProfile.vue'), + component: () => import('../views/Pages/UserProfileOverview.vue'), meta: { requiresAuth: true, }, }, - // { - // path: '/profileedit', - // component: () => import('../views/Pages/UserProfileEdit.vue'), - // meta: { - // requiresAuth: true, - // }, - // }, - // { - // path: '/activity', - // component: () => import('../views/Pages/UserProfileActivity.vue'), - // meta: { - // requiresAuth: true, - // }, - // }, { path: '/transactions', component: () => import('../views/Pages/UserProfileTransactionList.vue'), diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js index 1d89894fb..4c7e10a87 100644 --- a/frontend/src/store/store.js +++ b/frontend/src/store/store.js @@ -13,6 +13,18 @@ export const mutations = { sessionId: (state, sessionId) => { state.sessionId = sessionId }, + username: (state, username) => { + state.username = username + }, + firstName: (state, firstName) => { + state.firstName = firstName + }, + lastName: (state, lastName) => { + state.lastName = lastName + }, + description: (state, description) => { + state.description = description + }, } export const actions = { @@ -20,10 +32,18 @@ export const actions = { commit('sessionId', data.sessionId) commit('email', data.user.email) commit('language', data.user.language) + commit('username', data.user.username) + commit('firstName', data.user.first_name) + commit('lastName', data.user.last_name) + commit('description', data.user.description) }, logout: ({ commit, state }) => { commit('sessionId', null) commit('email', null) + commit('username', '') + commit('firstName', '') + commit('lastName', '') + commit('description', '') sessionStorage.clear() }, } @@ -39,6 +59,10 @@ export const store = new Vuex.Store({ email: '', language: null, modals: false, + firstName: '', + lastName: '', + username: '', + description: '', }, getters: {}, // Syncronous mutation of the state diff --git a/frontend/src/store/store.test.js b/frontend/src/store/store.test.js index 11dd5949b..6bc004273 100644 --- a/frontend/src/store/store.test.js +++ b/frontend/src/store/store.test.js @@ -40,7 +40,7 @@ describe('Vuex store', () => { { commit, state }, { sessionId: 1234, user: { email: 'someone@there.is', language: 'en' } }, ) - expect(commit).toHaveBeenCalledTimes(3) + expect(commit).toHaveBeenCalledTimes(7) }) it('commits sessionId', () => { @@ -74,7 +74,7 @@ describe('Vuex store', () => { it('calls two commits', () => { logout({ commit, state }) - expect(commit).toHaveBeenCalledTimes(2) + expect(commit).toHaveBeenCalledTimes(6) }) it('commits sessionId', () => { diff --git a/frontend/src/views/Layout/DashboardLayout_gdd.spec.js b/frontend/src/views/Layout/DashboardLayout_gdd.spec.js index 84c955042..62ce94322 100644 --- a/frontend/src/views/Layout/DashboardLayout_gdd.spec.js +++ b/frontend/src/views/Layout/DashboardLayout_gdd.spec.js @@ -78,7 +78,7 @@ describe('DashboardLayoutGdd', () => { }) it('has five items in the navbar', () => { - expect(navbar.findAll('ul > a')).toHaveLength(2) + expect(navbar.findAll('ul > a')).toHaveLength(3) }) it('has first item "send" in navbar', () => { @@ -103,21 +103,21 @@ describe('DashboardLayoutGdd', () => { expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/transactions') }) - // it('has tree items in the navbar', () => { - // expect(navbar.findAll('ul > li')).toHaveLength(3) - // }) - // - // it('has third item "My profile" in navbar', () => { - // expect(navbar.findAll('ul > li').at(2).text()).toEqual('site.navbar.my-profil') - // }) - // - // it.skip('has third item "My profile" linked to profile in navbar', async () => { - // navbar.findAll('ul > li > a').at(2).trigger('click') - // await flushPromises() - // await jest.runAllTimers() - // await flushPromises() - // expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/profile') - // }) + it('has tree items in the navbar', () => { + expect(navbar.findAll('ul > a')).toHaveLength(3) + }) + + it('has third item "My profile" in navbar', () => { + expect(navbar.findAll('ul > a').at(2).text()).toEqual('site.navbar.my-profil') + }) + + it.skip('has third item "My profile" linked to profile in navbar', async () => { + navbar.findAll('ul > a').at(2).trigger('click') + await flushPromises() + await jest.runAllTimers() + await flushPromises() + expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/profile') + }) // it('has fourth item "Settigs" in navbar', () => { // expect(navbar.findAll('ul > li').at(3).text()).toEqual('site.navbar.settings') diff --git a/frontend/src/views/Layout/DashboardLayout_gdd.vue b/frontend/src/views/Layout/DashboardLayout_gdd.vue index b7dfe2b93..70a35a40a 100755 --- a/frontend/src/views/Layout/DashboardLayout_gdd.vue +++ b/frontend/src/views/Layout/DashboardLayout_gdd.vue @@ -1,5 +1,5 @@