From b7823407c04958b143c2c37d7b7e465bdd7d4895 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 12 Jul 2023 15:42:27 -0300 Subject: mobile friendly --- .../demobank-ui/src/pages/WalletWithdrawForm.tsx | 98 ++++++++++++++++------ 1 file changed, 71 insertions(+), 27 deletions(-) (limited to 'packages/demobank-ui/src/pages/WalletWithdrawForm.tsx') diff --git a/packages/demobank-ui/src/pages/WalletWithdrawForm.tsx b/packages/demobank-ui/src/pages/WalletWithdrawForm.tsx index 3a53bbe48..4c4a38e57 100644 --- a/packages/demobank-ui/src/pages/WalletWithdrawForm.tsx +++ b/packages/demobank-ui/src/pages/WalletWithdrawForm.tsx @@ -25,14 +25,16 @@ import { RequestError, useTranslationContext, } from "@gnu-taler/web-util/browser"; -import { VNode, h } from "preact"; +import { Ref, VNode, h } from "preact"; import { useEffect, useRef, useState } from "preact/hooks"; import { useAccessAPI } from "../hooks/access.js"; import { notifyError } from "../hooks/notification.js"; import { buildRequestErrorMessage, undefinedIfEmpty } from "../utils.js"; import { ShowInputErrorLabel } from "./ShowInputErrorLabel.js"; +import { forwardRef } from "preact/compat"; const logger = new Logger("WalletWithdrawForm"); +const RefAmount = forwardRef(Amount); export function WalletWithdrawForm({ focus, @@ -68,6 +70,7 @@ export function WalletWithdrawForm({ ? i18n.str`balance is not enough` : undefined, }); + return (
  -
- -   - { - setAmountStr(e.currentTarget.value); - }} - /> - -
+ { + setAmountStr(v); + }} + error={errors?.amount} + ref={ref} + />

@@ -160,3 +146,61 @@ export function WalletWithdrawForm({ ); } + +export function Amount( + { + currency, + value, + error, + onChange, + }: { + error?: string; + currency: string; + value: string | undefined; + onChange?: (s: string) => void; + }, + ref: Ref, +): VNode { + return ( +
+
+ + { + if (onChange) { + onChange(e.currentTarget.value); + } + }} + /> +
+ +
+ ); +} -- cgit v1.2.3