diff options
Diffstat (limited to 'packages/web-util/src/forms/InputAmount.tsx')
-rw-r--r-- | packages/web-util/src/forms/InputAmount.tsx | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/packages/web-util/src/forms/InputAmount.tsx b/packages/web-util/src/forms/InputAmount.tsx index 7a8c08f76..31e83350e 100644 --- a/packages/web-util/src/forms/InputAmount.tsx +++ b/packages/web-util/src/forms/InputAmount.tsx @@ -3,11 +3,15 @@ import { VNode, h } from "preact"; import { UIFormProps } from "./FormProvider.js"; import { InputLine } from "./InputLine.js"; import { useField } from "./useField.js"; +import { noHandlerPropsAndNoContextForField } from "./InputArray.js"; export function InputAmount<T extends object, K extends keyof T>( props: { currency?: string } & UIFormProps<T, K>, ): VNode { - const { value } = useField<T, K>(props.name); + //FIXME: remove deprecated + const fieldCtx = useField<T, K>(props.name); + const { value } = + props.handler ?? fieldCtx ?? noHandlerPropsAndNoContextForField(props.name); const currency = !value || !(value as any).currency ? props.currency @@ -22,8 +26,10 @@ export function InputAmount<T extends object, K extends keyof T>( converter={{ //@ts-ignore fromStringUI: (v): AmountJson => { - - return Amounts.parse(`${currency}:${v}`) ?? Amounts.zeroOfCurrency(currency); + return ( + Amounts.parse(`${currency}:${v}`) ?? + Amounts.zeroOfCurrency(currency) + ); }, //@ts-ignore toStringUI: (v: AmountJson) => { |