@@ -2,15 +2,14 @@ import {FormEvent, FunctionComponent} from "react"
22import { HouseholdGroup } from "local4local"
33import { Button , Card } from "@radix-ui/themes"
44import { HouseholdHeading } from "./household-heading.tsx"
5- import { getWithDefault } from "../default.ts"
65import { LabelWithInfo } from "../info/label-with-info.tsx"
76import { titles } from '../info/titles.tsx' ;
87
98export const HouseholdForm : FunctionComponent < {
10- initialData ?: HouseholdGroup | null ;
9+ initialData ?: HouseholdGroup ,
1110 save : ( householdGroup : HouseholdGroup ) => void ,
1211 hide : ( ) => void ,
13- } > = ( { initialData, save, hide} ) => {
12+ } > = ( { initialData = new HouseholdGroup , save, hide} ) => {
1413 const onSubmit = ( event : FormEvent < HTMLFormElement > ) => {
1514 event . preventDefault ( )
1615 const form = event . currentTarget
@@ -34,31 +33,31 @@ export const HouseholdForm: FunctionComponent<{
3433 < form onSubmit = { onSubmit } >
3534 < div className = "radix-grid" >
3635 < LabelWithInfo data = { titles [ "type" ] } />
37- < input className = "form-input" type = "text" id = "type" name = "type" defaultValue = { initialData ? .type || "Huishoudens" } />
36+ < input className = "form-input" type = "text" id = "type" name = "type" defaultValue = { initialData . type } />
3837 </ div >
3938 < div className = "radix-grid" >
4039 < LabelWithInfo data = { titles [ "households_n" ] } />
41- < input className = "form-input" type = "number" id = "households_n" name = "households_n" defaultValue = { initialData ? .households_n || 200 } min = { 0 } />
40+ < input className = "form-input" type = "number" id = "households_n" name = "households_n" defaultValue = { initialData . households_n } min = { 0 } />
4241 </ div >
4342 < div className = "radix-grid" >
4443 < LabelWithInfo data = { titles [ "hasPV_r" ] } />
45- < input className = "form-input" type = "number" id = "hasPV_r" name = "hasPV_r" defaultValue = { getWithDefault ( initialData ? .hasPV_r , 0.2 ) * 100 } min = { 0 } max = { 100 } />
44+ < input className = "form-input" type = "number" id = "hasPV_r" name = "hasPV_r" defaultValue = { initialData . hasPV_r * 100 } min = { 0 } max = { 100 } />
4645 </ div >
4746 < div className = "radix-grid" >
4847 < LabelWithInfo data = { titles [ "hasHeatPump_r" ] } />
49- < input className = "form-input" type = "number" id = "hasHeatPump_r" name = "hasHeatPump_r" defaultValue = { getWithDefault ( initialData ? .hasHeatPump_r , 0.1 ) * 100 } min = { 0 } max = { 100 } />
48+ < input className = "form-input" type = "number" id = "hasHeatPump_r" name = "hasHeatPump_r" defaultValue = { initialData . hasHeatPump_r * 100 } min = { 0 } max = { 100 } />
5049 </ div >
5150 < div className = "radix-grid" >
5251 < LabelWithInfo data = { titles [ "hasChargePoint_r" ] } />
53- < input className = "form-input" type = "number" id = "hasChargePoint_r" name = "hasChargePoint_r" defaultValue = { getWithDefault ( initialData ? .hasChargePoint_r , 0.2 ) * 100 } min = { 0 } max = { 100 } />
52+ < input className = "form-input" type = "number" id = "hasChargePoint_r" name = "hasChargePoint_r" defaultValue = { initialData . hasChargePoint_r * 100 } min = { 0 } max = { 100 } />
5453 </ div >
5554 < div className = "radix-grid" >
5655 < LabelWithInfo data = { titles [ "hasHomeBattery_r" ] } />
57- < input className = "form-input" type = "number" id = "hasHomeBattery_r" name = "hasHomeBattery_r" defaultValue = { getWithDefault ( initialData ? .hasHomeBattery_r , 0.01 ) * 100 } min = { 0 } max = { 100 } />
56+ < input className = "form-input" type = "number" id = "hasHomeBattery_r" name = "hasHomeBattery_r" defaultValue = { initialData . hasHomeBattery_r * 100 } min = { 0 } max = { 100 } />
5857 </ div >
5958 < div className = "radix-grid" >
6059 < LabelWithInfo data = { titles [ "annualBaseConsumptionAvg_kWh" ] } />
61- < input className = "form-input" type = "number" id = "annualBaseConsumptionAvg_kWh" name = "annualBaseConsumptionAvg_kWh" defaultValue = { initialData ? .annualBaseConsumptionAvg_kWh || 3000 } min = { 0 } />
60+ < input className = "form-input" type = "number" id = "annualBaseConsumptionAvg_kWh" name = "annualBaseConsumptionAvg_kWh" defaultValue = { initialData . annualBaseConsumptionAvg_kWh } min = { 0 } />
6261 </ div >
6362 < Button type = "button" onClick = { hide } style = { { marginRight : '10px' } } highContrast variant = "soft" > Annuleren</ Button >
6463 < Button type = "submit" > Opslaan</ Button >
0 commit comments