36 lines
790 B
TypeScript
36 lines
790 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 { Supplier } from '../../../shared/types.ts'
|
|
|
|
const InvoicesPage: FunctionComponent = () => {
|
|
const [suppliers, setSuppliers] = useState<Supplier[]>([])
|
|
|
|
useEffect(() => {
|
|
rek('/api/suppliers').then(setSuppliers)
|
|
}, [])
|
|
|
|
return (
|
|
<section>
|
|
<Head>
|
|
<title> : Invoices</title>
|
|
</Head>
|
|
|
|
<h1>Invoices</h1>
|
|
<ul>
|
|
{suppliers?.map((supplier) => (
|
|
<li>
|
|
<a href={`/invoices/by-supplier/${supplier.id}`}>
|
|
({supplier.id}) {supplier.name}
|
|
</a>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</section>
|
|
)
|
|
}
|
|
|
|
export default InvoicesPage
|