Added load of clubs after login
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user