From cd6321d3034cfd5c31457fbe659fa5ae60f1cc04 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Fri, 4 Nov 2022 15:38:58 -0300
Subject: min 0 for amount

---
 .../src/wallet/DestinationSelection.tsx                    | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

(limited to 'packages/taler-wallet-webextension/src/wallet/DestinationSelection.tsx')

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>
-- 
cgit v1.2.3

