summaryrefslogtreecommitdiff
path: root/packages/demobank-ui/src/pages/WalletWithdrawForm.tsx
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-03-11 18:19:38 -0300
committerSebastian <sebasjm@gmail.com>2023-03-11 18:20:16 -0300
commitc67d94c56e154be4b2cf91572cdc2d8d2da7f8e4 (patch)
treefbb9444857d4e11f348c051b9c470e9295990096 /packages/demobank-ui/src/pages/WalletWithdrawForm.tsx
parentb72729f06535f12af974035b141a30320e75575c (diff)
downloadwallet-core-c67d94c56e154be4b2cf91572cdc2d8d2da7f8e4.tar.gz
wallet-core-c67d94c56e154be4b2cf91572cdc2d8d2da7f8e4.tar.bz2
wallet-core-c67d94c56e154be4b2cf91572cdc2d8d2da7f8e4.zip
fix: #7753
Diffstat (limited to 'packages/demobank-ui/src/pages/WalletWithdrawForm.tsx')
-rw-r--r--packages/demobank-ui/src/pages/WalletWithdrawForm.tsx25
1 files changed, 15 insertions, 10 deletions
diff --git a/packages/demobank-ui/src/pages/WalletWithdrawForm.tsx b/packages/demobank-ui/src/pages/WalletWithdrawForm.tsx
index c1ad2f0cf..8bbfe0713 100644
--- a/packages/demobank-ui/src/pages/WalletWithdrawForm.tsx
+++ b/packages/demobank-ui/src/pages/WalletWithdrawForm.tsx
@@ -14,7 +14,12 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { Amounts, HttpStatusCode, Logger } from "@gnu-taler/taler-util";
+import {
+ AmountJson,
+ Amounts,
+ HttpStatusCode,
+ Logger,
+} from "@gnu-taler/taler-util";
import {
RequestError,
useTranslationContext,
@@ -30,11 +35,11 @@ const logger = new Logger("WalletWithdrawForm");
export function WalletWithdrawForm({
focus,
- currency,
+ limit,
onError,
onSuccess,
}: {
- currency: string;
+ limit: AmountJson;
focus?: boolean;
onError: (e: PageStateType["error"]) => void;
onSuccess: (
@@ -52,20 +57,20 @@ export function WalletWithdrawForm({
if (focus) ref.current?.focus();
}, [focus]);
- // Beware: We never ever want to treat the amount as a float!
-
const trimmedAmountStr = amountStr?.trim();
const parsedAmount = trimmedAmountStr
- ? Amounts.parse(`${currency}:${trimmedAmountStr}`)
+ ? Amounts.parse(`${limit.currency}:${trimmedAmountStr}`)
: undefined;
const errors = undefinedIfEmpty({
amount:
trimmedAmountStr == null
? i18n.str`required`
- : parsedAmount == null
+ : !parsedAmount
? i18n.str`invalid`
+ : Amounts.cmp(limit, parsedAmount) === -1
+ ? i18n.str`balance is not enough`
: undefined,
});
return (
@@ -87,10 +92,10 @@ export function WalletWithdrawForm({
type="text"
readonly
class="currency-indicator"
- size={currency.length}
- maxLength={currency.length}
+ size={limit.currency.length}
+ maxLength={limit.currency.length}
tabIndex={-1}
- value={currency}
+ value={limit.currency}
/>
&nbsp;
<input