import apiClient from '@/plugins/axios';
import {BudgetCategory} from "@/models/Budget";
// Импортируете настроенный экземпляр axios

export const getBudgetInfo = async (budget_id: number) => {
    console.log('getBudgetInfo');
    let budgetInfo = await apiClient.get('/budgets/' + budget_id);
    budgetInfo = budgetInfo.data;

    budgetInfo.plannedExpenses.forEach(e => {
        e.date = new Date(e.date)
    })

    budgetInfo.plannedIncomes.forEach(e => {
        e.date = new Date(e.date)
    })

    budgetInfo.transactions.forEach(e => {
        e.date = new Date(e.date)
    })
    return budgetInfo

};

export const updateBudgetCategoryRequest = async (budget_id, category: BudgetCategory) => {
    await apiClient.put('/budgets/' + budget_id + '/category', category);
}