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
6 import { createMemo, createState } from 'solid-js';
7 import { For } from 'solid-js/dom';
8 import { Form, Person, TaxReturn } from 'ustaxlib/core';
10 import FormView from './FormView';
12 const S = require('./TaxReturnView.css');
18 export default function TaxReturnView(props: Props) {
19 const [ state, setState ] = createState({ form: props.tr.forms[0] });
21 const changeForm = e => {
22 setState({ form: props.tr.forms[e.target.value] });
25 const formIndexToName = createMemo(() => props.tr.forms.map((form, i) => {
27 const person = form.person();
28 if (person !== undefined) {
29 const personName = person === Person.joint ? 'Joint' : person.name;
30 name += ` (${personName})`;
35 const formSelector = (
36 <select onchange={changeForm}>
37 <For each={formIndexToName()}>
38 {tuple => (<option value={tuple[0]}>{tuple[1]}</option>)}
45 <div class={S.header}>
46 <h1>ustaxlib Federal {props.tr.year}</h1>
50 <FormView tr={props.tr} form={state.form as Form<any>} />