From eb1fa9b77f4e9bb613edc1652bdcf28c14db1356 Mon Sep 17 00:00:00 2001 From: Torsten Schulz Date: Wed, 25 Sep 2024 18:24:27 +0200 Subject: [PATCH] Added load of clubs after login --- frontend/src/store.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/store.js b/frontend/src/store.js index 88ca7eb..e127371 100644 --- a/frontend/src/store.js +++ b/frontend/src/store.js @@ -31,7 +31,7 @@ const store = createStore({ }, setClubsMutation(state, clubs) { state.clubs = clubs; - localStorage.setItem('clubs', JSON.stringify(clubs)); // Als JSON-String speichern + localStorage.setItem('clubs', JSON.stringify(clubs)); }, clearToken(state) { state.token = null; @@ -44,9 +44,11 @@ const store = createStore({ } }, actions: { - login({ commit }, { token, username }) { + async login({ commit }, { token, username }) { commit('setToken', token); commit('setUsername', username); + const response = await apiClient.get('/clubs'); + commit('setClubsMutation', response.data); }, logout({ commit }) { commit('clearToken'); @@ -67,8 +69,6 @@ const store = createStore({ currentClub: state => state.currentClub, clubs: state => state.clubs, currentClubName: state => { - console.log('Current Club ID:', state.currentClub); - console.log('Clubs:', state.clubs); const club = state.clubs.find(club => club.id === parseInt(state.currentClub)); if (club) { console.log('Found Club:', club.name);