45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import { h, type FunctionalComponent } from 'preact'
|
|
import { useEffect, useState } from 'preact/hooks'
|
|
import rek from 'rek'
|
|
|
|
import type { TransactionFull } from '../../../shared/types.ts'
|
|
|
|
interface Props {
|
|
objectId: number
|
|
}
|
|
|
|
const Result: FunctionalComponent<Props> = ({ objectId }) => {
|
|
const [transactions, setTransactions] = useState<TransactionFull[]>([])
|
|
|
|
useEffect(() => {
|
|
rek(`/api/objects/${objectId}`).then(setTransactions)
|
|
}, [objectId])
|
|
|
|
return (
|
|
<table className='grid'>
|
|
<thead>
|
|
<tr>
|
|
<th>Entry</th>
|
|
<th>Date</th>
|
|
<th>Account</th>
|
|
<th>Amount</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{transactions.map((transaction) => (
|
|
<tr>
|
|
<td>
|
|
<a href={`/entries/${transaction.entryId}`}>{transaction.entryId}</a>
|
|
</td>
|
|
<td>{transaction.transactionDate.slice(0, 10)}</td>
|
|
<td>{transaction.accountNumber}</td>
|
|
<td className='tar'>{transaction.amount}</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
)
|
|
}
|
|
|
|
export default Result
|