diff options
author | Santo Cariotti <santo@dcariotti.me> | 2021-03-19 16:06:10 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2021-03-19 16:06:10 +0100 |
commit | d383bd08f0266406d4b0c9eb68c76e62c9d4a460 (patch) | |
tree | 711ff41a90ca71d3fce90c2351afcd2ca1807144 /src | |
parent | 4410f2e46cbf961f2100038b53426bd07aebc4e9 (diff) |
feat: get emails
Diffstat (limited to 'src')
-rw-r--r-- | src/store.js | 22 | ||||
-rw-r--r-- | src/views/Home.vue | 6 |
2 files changed, 27 insertions, 1 deletions
diff --git a/src/store.js b/src/store.js index 9080bd0..888add2 100644 --- a/src/store.js +++ b/src/store.js @@ -7,16 +7,24 @@ export default new Vuex.Store({ state: { api: process.env.VUE_APP_BACKEND_URL, commits: [], + emails: {}, }, get: { commits: state => { return state.commits }, + emails: state => { + return state.emails + }, }, mutations: { load_commits: (state, value) => { state.commits = value }, + load_emails: (state, value) => { + console.log(JSON.stringify(value)) + state.emails = value + }, }, actions: { // Get all commits from the api backend @@ -26,6 +34,20 @@ export default new Vuex.Store({ commit('load_commits', await response.json()); }) }, + // Get all emails and map them like an hash + async get_emails({commit}) { + await fetch(`${this.state.api}/email/`) + .then(async response => { + const emails_list = await response.json(); + const emails_obj = emails_list + .reduce((dict, elem) => { + dict[elem['email']] = elem['hash_md5'] + return dict; + }, {}) + + commit('load_emails', emails_obj); + }) + }, }, modules: { } diff --git a/src/views/Home.vue b/src/views/Home.vue index 28da86b..e507ef8 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -15,11 +15,15 @@ export default { }, mounted() { this.$store.dispatch('get_commits'); + this.$store.dispatch('get_emails'); }, computed: { commits: () => { return this.$store.get.commits; - } + }, + emails: () => { + return this.$store.get.emails; + }, } } </script> |