34 lines
743 B
TypeScript
34 lines
743 B
TypeScript
import { h, type FunctionalComponent } from 'preact'
|
|
import { useEffect, useState } from 'preact/hooks'
|
|
import rek from 'rek'
|
|
|
|
import type { Transaction } from '../../../shared/types.ts'
|
|
|
|
interface Props {
|
|
year: number
|
|
}
|
|
|
|
const Invoices: FunctionalComponent<Props> = ({ year }) => {
|
|
const [invoices, setInvoices] = useState<Transaction[]>([])
|
|
|
|
useEffect(() => {
|
|
rek(`/api/invoices/by-year/${year}`).then(setInvoices)
|
|
}, [year])
|
|
|
|
return (
|
|
<table>
|
|
<tbody>
|
|
{invoices.map((invoice) => (
|
|
<tr>
|
|
<td>{invoice.accountNumber}</td>
|
|
<td>{invoice.description}</td>
|
|
<td>{invoice.amount}</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
)
|
|
}
|
|
|
|
export default Invoices
|