Implement budget display

This commit is contained in:
Jan Bader 2022-01-23 22:24:02 +00:00
parent aae8bbb44e
commit 6086447126
2 changed files with 40 additions and 1 deletions

View File

@ -1,8 +1,14 @@
<script> <script>
export default {
mounted () {
this.$store.dispatch("fetchBudget", this.$route.params.budgetid)
}
}
</script> </script>
<template> <template>
<h1>Budget</h1> <h1>Budget</h1>
<p>{{ $route.params.budgetid }}</p>
<p v-for="account in $store.getters.Accounts">{{ account.Name }} / {{ account.Balance.Int / 100 }}</p>
</template> </template>

View File

@ -0,0 +1,33 @@
const budget = {
state () {
return {
Accounts: [],
Categories: [],
Transactions: [],
Assignments: []
}
},
mutations: {
setAccounts (state, accounts) {
state.Accounts = accounts;
}
},
getters: {
Accounts(state) {
return state.Accounts || [];
}
},
actions: {
fetchBudget ({state, commit, rootState}, budgetid) {
fetch("/api/v1/budget/" + budgetid, {
headers: {
'Authorization': 'Bearer ' + rootState.Session.Token
}
})
.then(x => x.json())
.then(x => commit("setAccounts", x.Accounts));
}
}
}
export default budget