Use vue's Composition API in components #11

Merged
jacob1123 merged 9 commits from vue-composition into master 2022-02-15 10:13:47 +01:00
9 changed files with 158 additions and 162 deletions
Showing only changes of commit 57930d0e5d - Show all commits

View File

@ -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<number, Map<string, Category>>();
this.Months.set(year, yearMap);
addCategoriesForMonth(year: number, month: number, categories: Category[]): void {
this.$patch((state) => {
const yearMap = state.Months.get(year) || new Map<number, Map<string, Category>>();
const monthMap = yearMap.get(month) || new Map<string, Category>();
yearMap.set(month, monthMap);
for (const category of categories){
for (const category of categories) {
monthMap.set(category.ID, category);
}
yearMap.set(month, monthMap);
state.Months.set(year, yearMap);
});
},
logout() {
this.$reset()