()
| 13 | |
| 14 | |
| 15 | export default function LinksHTMLTable() { |
| 16 | const endpoint = "/api/links" |
| 17 | const {data, error, isLoading, mutate} = useSWR(endpoint, fetcher) |
| 18 | if (error) return "An error happened" |
| 19 | if (isLoading) return "Loading..." |
| 20 | const didSubmit = (newItem) => { |
| 21 | mutate() |
| 22 | } |
| 23 | return <> |
| 24 | <LinksCreateForm didSubmit={didSubmit} /> |
| 25 | <Table> |
| 26 | <Table.Head> |
| 27 | <Table.HeadCell> |
| 28 | ID |
| 29 | </Table.HeadCell> |
| 30 | <Table.HeadCell> |
| 31 | URL |
| 32 | </Table.HeadCell> |
| 33 | <Table.HeadCell> |
| 34 | Short Link |
| 35 | </Table.HeadCell> |
| 36 | </Table.Head> |
| 37 | <Table.Body className="divide-y"> |
| 38 | {data && data.map((link, idx)=>{ |
| 39 | return <Table.Row key={`link-${idx}`} className="bg-white dark:border-gray-700 dark:bg-gray-800"> |
| 40 | <Table.Cell className="whitespace-nowrap font-medium text-gray-900 dark:text-white"> |
| 41 | {link.id} |
| 42 | </Table.Cell> |
| 43 | <Table.Cell> |
| 44 | {link.url} |
| 45 | </Table.Cell> |
| 46 | <Table.Cell> |
| 47 | https://jref.io/{link.short} |
| 48 | </Table.Cell> |
| 49 | |
| 50 | </Table.Row> |
| 51 | })} |
| 52 | </Table.Body > |
| 53 | </Table> |
| 54 | |
| 55 | </> |
| 56 | } |
nothing calls this directly
no outgoing calls
no test coverage detected