diff --git a/web/src/stores/budget-account.ts b/web/src/stores/budget-account.ts index b8f36da..a56f0fc 100644 --- a/web/src/stores/budget-account.ts +++ b/web/src/stores/budget-account.ts @@ -104,16 +104,17 @@ export const useAccountStore = defineStore("budget/account", { const response = await result.json(); this.addCategoriesForMonth(year, month, response.Categories); }, - addCategoriesForMonth(year : number, month : number, categories : Category[]) : void { - const yearMap = this.Months.get(year) || new Map>(); - this.Months.set(year, yearMap); + addCategoriesForMonth(year: number, month: number, categories: Category[]): void { + this.$patch((state) => { + const yearMap = state.Months.get(year) || new Map>(); + const monthMap = yearMap.get(month) || new Map(); + for (const category of categories) { + monthMap.set(category.ID, category); + } - const monthMap = yearMap.get(month) || new Map(); - yearMap.set(month, monthMap); - - for (const category of categories){ - monthMap.set(category.ID, category); - } + yearMap.set(month, monthMap); + state.Months.set(year, yearMap); + }); }, logout() { this.$reset()