Add getters for current budget ID and Name

This commit is contained in:
2022-02-05 14:26:56 +00:00
parent 80b5a7abfe
commit ddaf647d87
4 changed files with 23 additions and 11 deletions

View File

@ -201,15 +201,27 @@ export const store = createStore<State>({
'Authorization': 'Bearer ' + state.Session.Token
}
},
CurrentBudget(state) {
CurrentBudget(state) : Budget | undefined {
if (state.CurrentBudgetID == null)
return {};
return undefined;
return state.Budgets.get(state.CurrentBudgetID) || {};
return state.Budgets.get(state.CurrentBudgetID);
},
CurrentAccount(state) {
CurrentBudgetID(state) : string | undefined {
return state.CurrentBudgetID;
},
CurrentBudgetName(state) : string {
if (state.CurrentBudgetID == null)
return "";
const currentBudget = state.Budgets.get(state.CurrentBudgetID);
if(currentBudget != undefined)
return currentBudget.Name;
return "";
},
CurrentAccount(state) : Account | undefined {
if (state.CurrentAccountID == null)
return { name: "Not found" };
return undefined;
return state.Accounts.get(state.CurrentAccountID);
},
OnBudgetAccounts(state) {