40 lines
1.1 KiB
XML

// /* Copyright (C) 2024 Manuel Bustillo*/
// import { Expense } from '@/app/lib/definitions';
// import { getCsrfToken, getSlug } from '@/app/lib/utils';
// export function loadExpenses(onLoad?: (expenses: Expense[]) => void) {
// fetch(`/api/${getSlug()}/expenses`)
// .then((response) => response.json())
// .then((data) => {
// onLoad && onLoad(data.map((record: any) => {
// return ({
// id: record.id,
// name: record.name,
// amount: record.amount,
// pricingType: record.pricing_type
// });
// }));
// }, (error) => {
// return [];
// });
// }
// export function updateExpense(expense: Expense) {
// fetch(`/api/${getSlug()}/expenses/${expense.id}`,
// {
// method: 'PUT',
// body: JSON.stringify({
// expense: {
// name: expense.name,
// amount: expense.amount,
// pricing_type: expense.pricingType,
// }
// }),
// headers: {
// 'Content-Type': 'application/json',
// 'X-CSRF-TOKEN': getCsrfToken(),
// }
// })
// .catch((error) => console.error(error));
// }