Implement Budget-List via Getter

This commit is contained in:
Jan Bader 2022-01-23 22:24:17 +00:00
parent 6086447126
commit 0bd63636bb
2 changed files with 6 additions and 6 deletions

View File

@ -1,10 +1,5 @@
<script> <script>
export default { export default {
computed: {
dashboard () {
return this.$store.state;
}
},
mounted () { mounted () {
this.$store.dispatch("fetchDashboard"); this.$store.dispatch("fetchDashboard");
} }
@ -12,7 +7,7 @@ export default {
</script> </script>
<template> <template>
<div v-if="dashboard != nil" v-for="budget in dashboard.Budgets" class="budget-item"> <div v-for="budget in $store.getters.Budgets" class="budget-item">
<router-link v-bind:to="'/budget/'+budget.ID">{{budget.Name}}</router-link> <router-link v-bind:to="'/budget/'+budget.ID">{{budget.Name}}</router-link>
<span class="time"></span> <span class="time"></span>
</div> </div>

View File

@ -10,6 +10,11 @@ const dashboard = {
state.Budgets = budgets; state.Budgets = budgets;
} }
}, },
getters: {
Budgets(state) {
return state.Budgets || [];
}
},
actions: { actions: {
fetchDashboard ({state, commit, rootState}) { fetchDashboard ({state, commit, rootState}) {
fetch("/api/v1/dashboard", { fetch("/api/v1/dashboard", {