diff --git a/web/src/pages/Budgeting.vue b/web/src/pages/Budgeting.vue index 8c4fc19..af123f5 100644 --- a/web/src/pages/Budgeting.vue +++ b/web/src/pages/Budgeting.vue @@ -4,46 +4,51 @@ import { FETCH_MONTH_BUDGET } from "../store/action-types"; import { TITLE } from "../store/mutation-types"; import Currency from "../components/Currency.vue"; +interface Date { + Year:Number, + Month:Number, +} + export default defineComponent({ mounted() { this.$store.commit(TITLE, "Budget for " + this.month + " " + this.year); - return this.$store.dispatch(FETCH_MONTH_BUDGET, { budgetid: this.budgetid, year: this.$data.Year, month: this.$data.Month }); + return this.$store.dispatch(FETCH_MONTH_BUDGET, { budgetid: this.budgetid, year: this.year, month: this.month }); }, watch: { year() { - return this.$store.dispatch(FETCH_MONTH_BUDGET, { budgetid: this.budgetid, year: this.$data.Year, month: this.$data.Month }); + return this.$store.dispatch(FETCH_MONTH_BUDGET, { budgetid: this.budgetid, year: this.year, month: this.month }); }, month() { - return this.$store.dispatch(FETCH_MONTH_BUDGET, { budgetid: this.budgetid, year: this.$data.Year, month: this.$data.Month }); + return this.$store.dispatch(FETCH_MONTH_BUDGET, { budgetid: this.budgetid, year: this.year, month: this.month }); }, }, props: ["budgetid", "year", "month"], - data() { - return { - Year: (this.year || new Date().getFullYear()) as number, - Month: (this.month || new Date().getMonth()) as number - }; - }, computed: { Categories() { - return this.$store.getters.Categories(this.$data.Year, this.$data.Month); + return this.$store.getters.Categories(this.year, this.month); }, - previous() { + previous() : Date { return { - Year: new Date(this.$data.Year, this.$data.Month - 1, 1).getFullYear(), - Month: new Date(this.$data.Year, this.$data.Month - 1, 1).getMonth(), + Year: new Date(this.year, this.month - 1, 1).getFullYear(), + Month: new Date(this.year, this.month - 1, 1).getMonth(), }; }, - current() { + current() : Date { return { Year: new Date().getFullYear(), Month: new Date().getMonth(), }; }, - next() { + selected() : Date { return { - Year: new Date(this.$data.Year, this.$data.Month + 1, 1).getFullYear(), - Month: new Date(this.$data.Year, this.$data.Month + 1, 1).getMonth(), + Year: this.year, + Month: Number(this.month) + 1 + } + }, + next() : Date { + return { + Year: new Date(this.year, Number(this.month) + 1, 1).getFullYear(), + Month: new Date(this.year, Number(this.month) + 1, 1).getMonth(), }; } }, @@ -57,7 +62,7 @@ export default defineComponent({