Remove unneeded assignment

This commit is contained in:
2022-01-24 19:22:38 +00:00
parent 746680a4d7
commit be821bc90a
4 changed files with 45 additions and 16 deletions

View File

@ -1,18 +1,20 @@
<script>
import NewBudget from '@/dialogs/NewBudget.vue';
export default {
mounted () {
mounted() {
this.$store.dispatch("fetchDashboard");
}
},
components: { NewBudget }
}
</script>
<template>
<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>
<div class="budget-item">
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#newbudgetmodal">New Budget</button>
<span class="time"></span>
</div>
<v-card cols="12" md="6" v-for="budget in $store.getters.Budgets" class="budget-item">
<v-card-title class="text-h5 grey lighten-2">
<router-link v-bind:to="'/budget/'+budget.ID">{{budget.Name}}</router-link>
</v-card-title>
<v-card-text><span class="time"></span></v-card-text>
</v-card>
<NewBudget />
</template>

View File

@ -32,7 +32,7 @@ const budget = {
})
.then(x => x.json())
.then(x => commit("setAccounts", x.Accounts));
}
},
}
}

View File

@ -7,7 +7,10 @@ const dashboard = {
},
mutations: {
setBudgets (state, budgets) {
state.Budgets = budgets;
state.Budgets = budgets;
},
addBudget(state, budget) {
state.Budgets.push(budget);
}
},
getters: {
@ -24,6 +27,17 @@ const dashboard = {
})
.then(x => x.json())
.then(x => commit("setBudgets", x.Budgets));
},
newBudget ({state, commit, rootState}, budgetName) {
fetch("/api/v1/budget/new", {
method: "POST",
body: JSON.stringify({name: budgetName}),
headers: {
'Authorization': 'Bearer ' + rootState.Session.Token
}
})
.then(x => x.json())
.then(x => commit("addBudget", x.Budget));
}
}
}