Migrate farther
This commit is contained in:
parent
2d0737a10c
commit
08330ce33c
@ -59,31 +59,6 @@ export const store = createStore<State>({
|
||||
await dispatch(FETCH_BUDGET, budgetid)
|
||||
},
|
||||
},
|
||||
getters: {
|
||||
AuthHeaders(state) {
|
||||
return {
|
||||
'Authorization': 'Bearer ' + state.Session.Token
|
||||
}
|
||||
},
|
||||
CurrentBudget(state) : Budget | undefined {
|
||||
if (state.CurrentBudgetID == null)
|
||||
return undefined;
|
||||
|
||||
return state.Budgets.get(state.CurrentBudgetID);
|
||||
},
|
||||
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 "";
|
||||
},
|
||||
},
|
||||
plugins: [createLogger()],
|
||||
modules: {
|
||||
budget: budgetStore
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { Budget, useSessionStore } from "./session";
|
||||
|
||||
interface State {
|
||||
CurrentBudgetID: string | null,
|
||||
@ -12,5 +13,20 @@ export const useBudgetsStore = defineStore('budget', {
|
||||
setCurrentBudgetID(budgetid : string) {
|
||||
this.CurrentBudgetID = budgetid;
|
||||
},
|
||||
},
|
||||
getters: {
|
||||
CurrentBudget() : Budget | undefined {
|
||||
if (this.CurrentBudgetID == null)
|
||||
return undefined;
|
||||
|
||||
const sessionStore = useSessionStore();
|
||||
return sessionStore.Budgets.get(this.CurrentBudgetID);
|
||||
},
|
||||
CurrentBudgetName(state) : string {
|
||||
return this.CurrentBudget?.Name ?? "";
|
||||
},
|
||||
CurrentBudgetID() : string | undefined {
|
||||
return this.CurrentBudgetID;
|
||||
},
|
||||
}
|
||||
})
|
@ -23,6 +23,11 @@ export const useSessionStore = defineStore('session', {
|
||||
Budgets(): IterableIterator<Budget> {
|
||||
return this.Budgets.values();
|
||||
},
|
||||
AuthHeaders(): Object {
|
||||
return {
|
||||
'Authorization': 'Bearer ' + this.Token
|
||||
}
|
||||
},
|
||||
/*// must define return type because of using `this`
|
||||
fullUserDetails (state): FullUserDetails {
|
||||
// import from other stores
|
||||
|
Loading…
x
Reference in New Issue
Block a user