diff --git a/src/store/index.js b/src/store/index.js index 329d9b0b684344a2d4a6da266d1715b3deb8c71e..eef57b2b52cbdccab9fc2c740888b4b501b446f8 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -47,7 +47,13 @@ export default new Vuex.Store({ SSO_SETTED: false, USER_LEVEL_PROJECTS: null, user_permissions: null, - messages: [] + messages: [], + events: null + // events: { + // 'events': null, + // 'features': null, + // 'comments': null + // } }, mutations: { @@ -90,6 +96,9 @@ export default new Vuex.Store({ SET_USER_PERMISSIONS(state, userPermissions) { state.user_permissions = userPermissions; }, + SET_EVENTS(state, events) { + state.events = events; + }, DISPLAY_MESSAGE(state, comment) { state.messages = [{ comment }, ...state.messages]; document.getElementById("messages").scrollIntoView({ block: "start", inline: "nearest" }); @@ -183,6 +192,23 @@ export default new Vuex.Store({ } }, + USER_EVENTS({ commit }) { + return new Promise((resolve, reject) => { + axios + .get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}events`) + .then((response) => { + if (response && response.status === 200) { + const events = response.data; + commit("SET_EVENTS", events); + resolve(response.data); + } + }) + .catch(() => { + reject("Error"); + }); + }); + }, + LOGOUT({ commit, dispatch }) { // const pageNoRedirect = ["liste-signalements", "details-type-signalement", "details-signalement", "project_detail", "mentions", "aide", "index"] axios diff --git a/src/views/My_account.vue b/src/views/My_account.vue index e9f4e9249a7cb07239e52a13d15ba80dcde4900f..8967257b25442a46f9958b202ce1d76486e78d01 100644 --- a/src/views/My_account.vue +++ b/src/views/My_account.vue @@ -309,6 +309,21 @@ export default { refreshId() { return "?ver=" + Math.random(); }, + setEvents(data){ + this.events = data.events; + this.features = data.features; + this.comments = data.comments; + }, + getEvents(){ + this.$store + .dispatch("USER_EVENTS") + .then((data)=>{ + this.setEvents(data) + }) + } }, + created(){ + this.getEvents(); + } }; </script> \ No newline at end of file