Save new group

This commit is contained in:
Jan Bader 2022-09-23 19:20:33 +00:00
parent fc15d8b56e
commit 5658f31457

View File

@ -6,6 +6,7 @@ import { Budget, useSessionStore } from "./session";
interface State {
Categories: Map<string, Category>;
CategoryGroups: Map<string, CategoryGroup>;
}
export interface Category {
@ -17,9 +18,15 @@ export interface Category {
Activity: number;
}
export interface CategoryGroup {
ID: string;
Name: string;
}
export const useCategoryStore = defineStore("category", {
state: (): State => ({
Categories: new Map<string, Category>(),
CategoryGroups: new Map<string, CategoryGroup>(),
}),
getters: {
},
@ -35,7 +42,7 @@ export const useCategoryStore = defineStore("category", {
})
);
const response = await result.json();
useCategoryStore().AddCategory(response);
useCategoryStore().AddCategoryGroup(response);
},
async CreateCategory(
group: string,
@ -54,6 +61,9 @@ export const useCategoryStore = defineStore("category", {
},
async AddCategory(category : Category){
this.Categories.set(category.ID, category);
},
async AddCategoryGroup(categoryGroup : CategoryGroup){
this.CategoryGroups.set(categoryGroup.ID, categoryGroup);
}
},
});