brf/client/public/components/accounts_page.tsx
2026-06-15 14:09:28 +02:00

39 lines
916 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>
<a href={`/accounts/${account.number}`}>{account.number}</a>
</td>
<td>{account.description}</td>
</tr>
))}
</tbody>
</table>
</section>
)
}
export default AccountsPage