Finish basic styling for the viewer.
[ustaxviewer.git] / src / FormView.tsx
1 import { createMemo } from 'solid-js';
2 import { For } from 'solid-js/dom';
3 import { TaxReturn, Form } from 'ustaxlib';
4
5 const S = require('./FormView.css');
6
7 interface FormProps {
8 tr: TaxReturn;
9 form: Form<any>;
10 }
11
12 export default function FormView(props: FormProps) {
13 const lineKeys = createMemo(() => Object.keys(props.form.lines));
14
15 return (
16 <>
17 <h2 class={S.formName}>Form {props.form.name}</h2>
18
19 <table class={S.table}>
20 <For each={lineKeys()}>
21 {key => <Line tr={props.tr} line={props.form.lines[key]} />}
22 </For>
23 </table>
24 </>
25 );
26 }
27
28 function Line(props: { tr, line }) {
29 const { tr, line } = props;
30 return (
31 <tr class={S.line}>
32 <th class={S.id}>{line.id}</th>
33 <td class={S.description}>{line.description}</td>
34 <td class={S.value}>{line.value(tr)}</td>
35 </tr>
36 );
37 }