create-categories #79

Open
jacob1123 wants to merge 31 commits from create-categories into master
Showing only changes of commit 5658f31457 - Show all commits

View File

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