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