diff --git a/web/src/pages/Budgeting.vue b/web/src/pages/Budgeting.vue index 684d51b..bf00f8c 100644 --- a/web/src/pages/Budgeting.vue +++ b/web/src/pages/Budgeting.vue @@ -15,13 +15,15 @@ const budgetsStore = useBudgetsStore(); const CurrentBudgetID = computed(() => budgetsStore.CurrentBudgetID); const accountStore = useAccountStore(); -const categoriesForMonth = accountStore.CategoriesForMonth; -const Categories = computed(() => { - return [...categoriesForMonth(selected.value.Year, selected.value.Month)]; -}); -const hiddenCategoriesForMonth = accountStore.HiddenCategoriesForMonth; -const HiddenCategories = computed(() => { - return [...hiddenCategoriesForMonth(selected.value.Year, selected.value.Month)]; +const categoriesForMonth = accountStore.CategoriesForMonthAndGroup; + +function GetCategories(group : string) { + return [...categoriesForMonth(selected.value.Year, selected.value.Month, group)]; +}; + +const groupsForMonth = accountStore.CategoryGroupsForMonth; +const GroupsForMonth = computed(() => { + return [...groupsForMonth(selected.value.Year, selected.value.Month)]; }); @@ -67,7 +69,6 @@ onMounted(() => { - @@ -76,41 +77,25 @@ onMounted(() => { - - - - - - - - - - - - - - - - - - - - + +

{{ group }}

+ + + + + + + + + +
Group Category Activity Available
{{ category.Group }}{{ category.Name }} - - - - - - - -
{{ category.Group }}{{ category.Name }} - - - - - - - -
{{ category.Name }} + + + + + + + +
diff --git a/web/src/stores/budget-account.ts b/web/src/stores/budget-account.ts index a265cda..be57f7d 100644 --- a/web/src/stores/budget-account.ts +++ b/web/src/stores/budget-account.ts @@ -54,17 +54,29 @@ export const useAccountStore = defineStore("budget/account", { AccountsList(state) { return [...state.Accounts.values()]; }, - CategoriesForMonth: (state) => (year: number, month: number) => { + AllCategoriesForMonth: (state) => (year: number, month: number) => { const yearMap = state.Months.get(year); const monthMap = yearMap?.get(month); - console.log("MTH", monthMap) - return [...monthMap?.values() || []].filter(x => x.Group != "Hidden Categories"); + return [...monthMap?.values() || []]; }, - HiddenCategoriesForMonth: (state) => (year: number, month: number) => { - const yearMap = state.Months.get(year); - const monthMap = yearMap?.get(month); - console.log("MTH", monthMap) - return [...monthMap?.values() || []].filter(x => x.Group == "Hidden Categories"); + CategoryGroupsForMonth(state) { + return (year: number, month: number) => { + const categories = this.AllCategoriesForMonth(year, month); + const categoryGroups = []; + let prev = undefined; + for (const category of categories) { + if(category.Group != prev) + categoryGroups.push(category.Group); + prev = category.Group; + } + return categoryGroups; + } + }, + CategoriesForMonthAndGroup(state) { + return (year: number, month: number, group : string) => { + const categories = this.AllCategoriesForMonth(year, month); + return categories.filter(x => x.Group == group); + } }, CurrentAccount(state): Account | undefined { if (state.CurrentAccountID == null)