/* Copyright (C) 2024 Manuel Bustillo*/ 'use client' import React, { useState } from "react" import { Expense } from '@/app/lib/definitions'; import TableOfContents from "../components/table-of-contents"; export default function ExpensesTable() { const [expenses, setExpenses] = useState>([]); function loadExpenses() { fetch("/api/expenses") .then((response) => response.json()) .then((data) => { setExpenses(data.map((record: any) => { return ({ id: record.id, name: record.name, amount: record.amount, pricingType: record.pricing_type }); })); }, (error) => { return []; }); } expenses.length === 0 && loadExpenses(); return ( ( {expense.name} {expense.amount}€ {expense.pricingType} )} /> ); }