brf/client/public/components/accounts_page.tsx

37 lines
840 B
TypeScript

import { h, type FunctionComponent } from 'preact'
import rek from 'rek'
import Head from './head.ts'
import usePromise from '../../shared/hooks/use_promise.ts'
import type { Account } from '../../../shared/types.db.ts'
const AccountsPage: FunctionComponent = () => {
const accounts = usePromise<Account[]>(() => rek('/api/accounts'))
return (
<section>
<Head>
<title> : Konton</title>
</Head>
<h1>Konton</h1>
<table className='grid'>
<thead>
<th>Nummer</th>
<th>Beskrivning</th>
</thead>
<tbody>
{accounts.map((account) => (
<tr>
<td>{account.number}</td>
<td>{account.description}</td>
</tr>
))}
</tbody>
</table>
</section>
)
}
export default AccountsPage