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>
export default {
computed: {
dashboard () {
return this.$store.state;
}
},
mounted () {
this.$store.dispatch("fetchDashboard");
}
@ -12,7 +7,7 @@ export default {
</script>
<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>
<span class="time"></span>
</div>

View File

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