This commit is contained in:
Vladimir Voronin
2024-11-06 19:14:53 +03:00
parent 04fae4dec7
commit 9d546f6069
23 changed files with 1008 additions and 108 deletions

View File

@@ -1,5 +1,6 @@
import apiClient from '@/services/axiosSetup';
import {Budget, BudgetCategory} from "@/models/Budget";
import {format} from "date-fns";
// Импортируете настроенный экземпляр axios
export const getBudgetInfos = async () => {
@@ -31,7 +32,7 @@ export const getBudgetTransactions = async (budgetId, transactionType, categoryT
url += '?type=' + transactionType
}
if (transactionType && categoryType) {
url += '/'+transactionType+'/'+categoryType
url += '/' + transactionType + '/' + categoryType
}
// if (!categoryType) {
// throw new Error('No CategoryType');
@@ -67,4 +68,16 @@ export const getBudgetInfo = async (budget_id: number) => {
export const updateBudgetCategoryRequest = async (budget_id, category: BudgetCategory) => {
await apiClient.put('/budgets/' + budget_id + '/category', category);
}
export const createBudget = async (budget: Budget, createRecurrent: Boolean) => {
budget.dateFrom = format(budget.dateFrom, 'yyyy-MM-dd')
budget.dateTo = format(budget.dateTo, 'yyyy-MM-dd')
let data = {
budget: budget,
createRecurrent: createRecurrent
}
await apiClient.post('/budgets', data);
budget.dateFrom = format(budget.dateFrom, 'dd.mm.yy')
budget.dateTo = format(budget.dateTo, 'dd.mm.yy')
}