merchant-backoffice

ZZZ: Inactive/Deprecated
Log | Files | Refs | Submodules | README

commit cfd4303db0a908fca7cb2540e58fa75e36a7d4d2
parent 8d4a44f7faf931f783a34ecc1136d7c23cca0c25
Author: ms <ms@taler.net>
Date:   Wed,  9 Feb 2022 19:02:52 +0100

collect amount to withdraw

Diffstat:
Mpackages/bank/src/pages/home/index.tsx | 48++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 42 insertions(+), 6 deletions(-)

diff --git a/packages/bank/src/pages/home/index.tsx b/packages/bank/src/pages/home/index.tsx @@ -620,6 +620,45 @@ async function registrationCall( *************************/ /** + * Let user choose a amount and submit the withdtawal. + */ +function TalerWithdrawal(Props: any): VNode { + const {backendState, pageStateSetter} = Props; + const i18n = useTranslator(); + const amountRegex = "^[0-9]+(\.[0-9]+)?$"; + var submitAmount = ""; // without currency. + var submitButton = <button + onClick={() => { + console.log("Maybe valid amount", submitAmount); + submitAmount = submitAmount.replace(",", "."); // tolerating comma instead of point. + const re = RegExp(amountRegex) + if (!re.test(submitAmount)) { + console.log("Not withdrawing invalid amount", submitAmount); + return; + } + console.log("Valid amount", submitAmount); + createWithdrawalCall( + `EUR:${submitAmount}`, // FIXME: take currency from the balance. + backendState, + pageStateSetter + )}}>{i18n`Charge Taler wallet`} + </button>; + + return <Fragment> + <input + type="text" + placeholder="amount" + required + pattern={amountRegex} + onInput={(e): void => { + submitAmount = e.currentTarget.value + }} /> + <label>FIXME: currency here!</label> + { submitButton } + </Fragment> +} + +/** * Collect and submit login data. */ function LoginForm(Props: any): VNode { @@ -974,12 +1013,9 @@ export function BankHome(): VNode { * No action is currently being performed (page is 'pristine'): * offer the Taler withdrawal button. */ - !pageState.withdrawalInProgress && !pageState.transferOutcome && <button onClick={() => { - createWithdrawalCall( - "EUR:5", - backendState, - pageStateSetter - )}}>{i18n`Charge Taler wallet`}</button> + !pageState.withdrawalInProgress && !pageState.transferOutcome && <TalerWithdrawal + backendState={backendState} + pageStateSetter={pageStateSetter} /> } { /**