Add license information.
[ustaxviewer.git] / src / TaxReturnView.tsx
1 // Copyright 2020 Blue Static <https://www.bluestatic.org>
2 // This program is free software licensed under the GNU General Public License,
3 // version 3.0. The full text of the license can be found in LICENSE.txt.
4 // SPDX-License-Identifier: GPL-3.0-only
5
6 import { createMemo, createState } from 'solid-js';
7 import { For } from 'solid-js/dom';
8 import { Form, TaxReturn } from 'ustaxlib/core';
9
10 import FormView from './FormView';
11
12 const S = require('./TaxReturnView.css');
13
14 interface Props {
15 tr: TaxReturn;
16 }
17
18 export default function TaxReturnView(props: Props) {
19 const [ state, setState ] = createState({ form: props.tr.forms[0] });
20
21 const changeForm = e => {
22 setState({ form: props.tr.forms[e.target.value] });
23 };
24
25 const formIndexToName = createMemo(() => props.tr.forms.map((form, i) => [i, form.name]));
26
27 const formSelector = (
28 <select onchange={changeForm}>
29 <For each={formIndexToName()}>
30 {tuple => (<option value={tuple[0]}>{tuple[1]}</option>)}
31 </For>
32 </select>
33 );
34
35 return (
36 <div>
37 <div class={S.header}>
38 <h1>ustaxlib Federal {props.tr.year}</h1>
39 {formSelector}
40 </div>
41
42 <FormView tr={props.tr} form={state.form as Form<any>} />
43 </div>
44 );
45 }
46