summaryrefslogtreecommitdiff
path: root/src/store.js
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2021-03-19 16:06:10 +0100
committerSanto Cariotti <santo@dcariotti.me>2021-03-19 16:06:10 +0100
commitd383bd08f0266406d4b0c9eb68c76e62c9d4a460 (patch)
tree711ff41a90ca71d3fce90c2351afcd2ca1807144 /src/store.js
parent4410f2e46cbf961f2100038b53426bd07aebc4e9 (diff)
feat: get emails
Diffstat (limited to 'src/store.js')
-rw-r--r--src/store.js22
1 files changed, 22 insertions, 0 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: {
}