Implement budget display
This commit is contained in:
parent
aae8bbb44e
commit
6086447126
@ -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>
|
33
web/src/store/budget/index.js
Normal file
33
web/src/store/budget/index.js
Normal 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
|
Loading…
x
Reference in New Issue
Block a user