1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/** @jsxImportSource npm:preact */
import { RenderFunc } from "https://esm.town/v/pomdtr/invoice_schema";
import clsx from "npm:clsx";
import { render as preactRender } from "npm:preact-render-to-string";
export const render: RenderFunc = ({ title, table, to, from, details }) => {
return preactRender(
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{title}</title>
<link rel="icon" href="https://fav.farm/📃" />
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-white">
<header>
<section>
<div class="px-8 py-24 flex flex-col mx-auto justify-center sm:px-12 lg:px-24 max-w-6xl">
<div class="flex justify-between items-start">
<div class="text-left text-sm space-y-1 text-gray-500">
{from.map((value) => <p>{value}</p>)}
</div>
<div class="text-right text-sm space-y-1 text-gray-500">
{to.map((value) => <p>{value}</p>)}
</div>
</div>
<div class="sm:flex sm:items-center mt-12">
<div class="sm:flex-auto">
<h1 class="text-xl">{title}</h1>
</div>
</div>
<div class="-mx-4 mt-24 flow-root sm:mx-0">
<table class="min-w-full">
<thead class="border-b border-gray-300 text-gray-900">
<tr>
{table.columns.map((column, idx) => (
<th
scope="col"
class={`px-3 py-3.5 text-left ${
clsx({
"text-left": idx == 0,
"text-right": idx > 0,
})
}`}
>
{column}
</th>
))}
</tr>
</thead>
<tbody>
{table.rows.map((row) => (
<tr class="border-b border-gray-200">
{row.map((item, idx) => (
<td
class={`hidden px-3 py-5 text-sm text-gray-500 sm:table-cell ${
clsx({
"text-left": idx == 0,
"text-right": idx > 0,
})
}`}
>
{item}
</td>
))}
</tr>
))}
</tbody>
<tfoot>
{table.summary.map(([key, value]) => (
<tr class="text-right">
<th
scope="row"
colspan={table.columns.length - 1}
class="hidden pl-4 pr-3 pt-6 sm:table-cell sm:pl-0"
>
{key}
</th>
<td class="pl-3 pr-4 pt-6 sm:pr-0 text-gray-500">{value}</td>
</tr>
))}
</tfoot>
</table>
</div>
<div class="flex justify-between mt-12 items-start">
<div class="text-left text-sm space-y-1 text-gray-500">
{details.map(([title, value]) => (
<p>
<strong>{title}:</strong> {value}
</p>
))}
</div>
</div>
</div>
</section>
</header>
</body>