Added counts to each category

Counts update on certain events and show or hide various elements
Fixed various little ui element issues

fixes #6
This commit is contained in:
Max G
2020-02-11 21:11:14 +00:00
parent cf3289aac6
commit 05152cd5a4
14 changed files with 169 additions and 39 deletions

View File

@@ -12,6 +12,7 @@ export default new Vuex.Store({
isUserOnMobile: false,
isNoteSettingsOpen: false, //Little note settings pane
socket: null,
userTotals: null,
},
mutations: {
setLoginToken(state, userData){
@@ -88,6 +89,14 @@ export default new Vuex.Store({
//Put socket id in axios headers
axios.defaults.headers.common['socketId'] = socket
state.socket = socket
},
setUserTotals(state, totalsObject){
//Save all the totals for the user
state.userTotals = totalsObject
// Object.keys(totalsObject).forEach( key => {
// console.log(key + ' -- ' + totalsObject[key])
// })
}
},
@@ -114,5 +123,16 @@ export default new Vuex.Store({
getSocket: state => {
return state.socket
},
totals: state => {
return state.userTotals
},
},
actions: {
fetchAndUpdateUserTotals ({ commit }) {
axios.post('/api/user/totals')
.then( ({data}) => {
commit('setUserTotals', data)
})
}
}
})