aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/wallet
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2022-11-04 15:38:58 -0300
committerSebastian <sebasjm@gmail.com>2022-11-04 15:38:58 -0300
commitcd6321d3034cfd5c31457fbe659fa5ae60f1cc04 (patch)
treed08c7f4b3aafc70152643c6858ffc7c56f8420aa /packages/taler-wallet-webextension/src/wallet
parent8af72c6036c93ea0d80ca127ae2db0e9c98f5af9 (diff)
downloadwallet-core-cd6321d3034cfd5c31457fbe659fa5ae60f1cc04.tar.xz
min 0 for amount
Diffstat (limited to 'packages/taler-wallet-webextension/src/wallet')
-rw-r--r--packages/taler-wallet-webextension/src/wallet/DestinationSelection.tsx14
-rw-r--r--packages/taler-wallet-webextension/src/wallet/ExchangeSelection/views.tsx16
2 files changed, 21 insertions, 9 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/DestinationSelection.tsx b/packages/taler-wallet-webextension/src/wallet/DestinationSelection.tsx
index 1e52f11bc..c584f2aae 100644
--- a/packages/taler-wallet-webextension/src/wallet/DestinationSelection.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/DestinationSelection.tsx
@@ -283,6 +283,11 @@ export function DestinationSelectionGetCash({
const [currency, setCurrency] = useState(parsedInitialAmount?.currency);
const [amount, setAmount] = useState(parsedInitialAmountValue);
+ function positiveSetAmount(e: string):void {
+ const value = Number.parseInt(e, 10);
+ if (value < 0) return
+ setAmount(String(value))
+ }
const { i18n } = useTranslationContext();
const previous1: Contact[] = [];
const previous2: Contact[] = [
@@ -324,6 +329,7 @@ export function DestinationSelectionGetCash({
<TextField
label="Amount"
type="number"
+ min="0"
variant="filled"
error={invalid}
required
@@ -425,6 +431,11 @@ export function DestinationSelectionSendCash({
const currency = parsedInitialAmount?.currency;
const [amount, setAmount] = useState(parsedInitialAmountValue);
+ function positiveSetAmount(e: string):void {
+ const value = Number.parseInt(e, 10);
+ if (value < 0) return
+ setAmount(String(value))
+ }
const { i18n } = useTranslationContext();
const previous1: Contact[] = [];
const previous2: Contact[] = [
@@ -466,6 +477,7 @@ export function DestinationSelectionSendCash({
<TextField
label="Amount"
type="number"
+ min="0"
variant="filled"
required
error={invalid}
@@ -474,7 +486,7 @@ export function DestinationSelectionSendCash({
}
value={amount}
onChange={(e) => {
- setAmount(e);
+ positiveSetAmount(e);
}}
/>
</div>
diff --git a/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/views.tsx b/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/views.tsx
index e89fc8879..d9a33c5c2 100644
--- a/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/views.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/views.tsx
@@ -19,6 +19,7 @@ import { styled } from "@linaria/react";
import { Fragment, h, VNode } from "preact";
import { useState } from "preact/hooks";
import { Amount } from "../../components/Amount.js";
+import { ErrorMessage } from "../../components/ErrorMessage.js";
import { LoadingError } from "../../components/LoadingError.js";
import { SelectList } from "../../components/SelectList.js";
import { Input, SvgIcon } from "../../components/styled/index.js";
@@ -156,17 +157,16 @@ export function NoExchangesView({
const { i18n } = useTranslationContext();
if (!currency) {
return (
- <div>
- <i18n.Translate>could not find any exchange</i18n.Translate>
- </div>
+ <ErrorMessage
+ title={<i18n.Translate>Could not find any exchange</i18n.Translate>}
+ />
);
+
}
return (
- <div>
- <i18n.Translate>
- could not find any exchange for the currency {currency}
- </i18n.Translate>
- </div>
+ <ErrorMessage
+ title={<i18n.Translate>Could not find any exchange for the currency {currency}</i18n.Translate>}
+ />
);
}