41 lines
895 B
TypeScript
41 lines
895 B
TypeScript
import { h, type FunctionComponent } from 'preact'
|
|
import { useEffect, useState } from 'preact/hooks'
|
|
import rek from 'rek'
|
|
import Head from './head.ts'
|
|
|
|
import type { Account } from '../../../shared/types.ts'
|
|
|
|
const AccountsPage: FunctionComponent = () => {
|
|
const [accounts, setAccounts] = useState<Account[]>([])
|
|
|
|
useEffect(() => {
|
|
rek('/api/accounts').then(setAccounts)
|
|
}, [])
|
|
|
|
return (
|
|
<section>
|
|
<Head>
|
|
<title> : Accounts</title>
|
|
</Head>
|
|
|
|
<h1>Accounts</h1>
|
|
<table className='grid'>
|
|
<thead>
|
|
<th>Number</th>
|
|
<th>Description</th>
|
|
</thead>
|
|
<tbody>
|
|
{accounts.map((account) => (
|
|
<tr>
|
|
<td>{account.number}</td>
|
|
<td>{account.description}</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
</section>
|
|
)
|
|
}
|
|
|
|
export default AccountsPage
|