Actually call API on save

This commit is contained in:
2022-09-11 20:47:12 +00:00
parent 0c375884aa
commit 0567619408
4 changed files with 20 additions and 22 deletions

View File

@@ -1,13 +1,13 @@
import { defineStore } from "pinia";
import { GET, POST } from "../api";
import { useBudgetsStore } from "./budget";
import { Category } from "./category";
import { useSessionStore } from "./session";
import { Transaction, useTransactionsStore } from "./transactions";
interface State {
Accounts: Map<string, Account>;
CurrentAccountID: string | null;
Categories: Map<string, Category>;
Months: Map<number, Map<number, Map<string, Category>>>;
Available: number,
OverspentLastMonth: number,
@@ -31,15 +31,6 @@ interface NullDate {
Time: Date;
}
export interface Category {
ID: string;
Group: string;
Name: string;
AvailableLastMonth: number;
Assigned: number;
Activity: number;
}
interface BudgetedAmounts {
Assigned: number,
Deassigned: number,
@@ -54,7 +45,6 @@ export const useAccountStore = defineStore("budget/account", {
Months: new Map<number, Map<number, Map<string, Category>>>(),
Available: 0,
OverspentLastMonth: 0,
Categories: new Map<string, Category>(),
Assignments: [],
}),
getters: {

View File

@@ -1,6 +1,7 @@
import { defineStore } from "pinia";
import { GET, POST } from "../api";
import { useAccountStore } from "./budget-account";
import { useCategoryStore } from "./category";
import { Budget, useSessionStore } from "./session";
interface State {
@@ -62,8 +63,10 @@ export const useBudgetsStore = defineStore("budget", {
);
accounts.Accounts.set(account.ID, account);
}
const categories = useCategoryStore();
for (const category of response.Categories || []) {
accounts.Categories.set(category.ID, category);
categories.Categories.set(category.ID, category);
}
},
},