Do not use a store for API
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { useAPI } from "./api";
|
||||
import { GET, POST } from "../api";
|
||||
import { useAccountStore } from "./budget-account";
|
||||
import { Budget, useSessionStore } from "./session";
|
||||
|
||||
@ -25,15 +25,13 @@ export const useBudgetsStore = defineStore('budget', {
|
||||
},
|
||||
actions: {
|
||||
ImportYNAB(formData: FormData) {
|
||||
const api = useAPI();
|
||||
return api.POST(
|
||||
return POST(
|
||||
"/budget/" + this.CurrentBudgetID + "/import/ynab",
|
||||
formData,
|
||||
);
|
||||
},
|
||||
async NewBudget(budgetName: string): Promise<void> {
|
||||
const api = useAPI();
|
||||
const result = await api.POST(
|
||||
const result = await POST(
|
||||
"/budget/new",
|
||||
JSON.stringify({ name: budgetName })
|
||||
);
|
||||
@ -51,8 +49,7 @@ export const useBudgetsStore = defineStore('budget', {
|
||||
await this.FetchBudget(budgetid);
|
||||
},
|
||||
async FetchBudget(budgetid: string) {
|
||||
const api = useAPI();
|
||||
const result = await api.GET("/budget/" + budgetid);
|
||||
const result = await GET("/budget/" + budgetid);
|
||||
const response = await result.json();
|
||||
for (const account of response.Accounts || []) {
|
||||
useAccountStore().Accounts.set(account.ID, account);
|
||||
|
Reference in New Issue
Block a user