min 0 for amount
This commit is contained in:
parent
8af72c6036
commit
cd6321d303
@ -40,6 +40,7 @@ export interface Props {
|
|||||||
minRows?: number;
|
minRows?: number;
|
||||||
multiline?: boolean;
|
multiline?: boolean;
|
||||||
onChange?: (s: string) => void;
|
onChange?: (s: string) => void;
|
||||||
|
min?: string;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
|
|
||||||
|
@ -283,6 +283,11 @@ export function DestinationSelectionGetCash({
|
|||||||
const [currency, setCurrency] = useState(parsedInitialAmount?.currency);
|
const [currency, setCurrency] = useState(parsedInitialAmount?.currency);
|
||||||
|
|
||||||
const [amount, setAmount] = useState(parsedInitialAmountValue);
|
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 { i18n } = useTranslationContext();
|
||||||
const previous1: Contact[] = [];
|
const previous1: Contact[] = [];
|
||||||
const previous2: Contact[] = [
|
const previous2: Contact[] = [
|
||||||
@ -324,6 +329,7 @@ export function DestinationSelectionGetCash({
|
|||||||
<TextField
|
<TextField
|
||||||
label="Amount"
|
label="Amount"
|
||||||
type="number"
|
type="number"
|
||||||
|
min="0"
|
||||||
variant="filled"
|
variant="filled"
|
||||||
error={invalid}
|
error={invalid}
|
||||||
required
|
required
|
||||||
@ -425,6 +431,11 @@ export function DestinationSelectionSendCash({
|
|||||||
const currency = parsedInitialAmount?.currency;
|
const currency = parsedInitialAmount?.currency;
|
||||||
|
|
||||||
const [amount, setAmount] = useState(parsedInitialAmountValue);
|
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 { i18n } = useTranslationContext();
|
||||||
const previous1: Contact[] = [];
|
const previous1: Contact[] = [];
|
||||||
const previous2: Contact[] = [
|
const previous2: Contact[] = [
|
||||||
@ -466,6 +477,7 @@ export function DestinationSelectionSendCash({
|
|||||||
<TextField
|
<TextField
|
||||||
label="Amount"
|
label="Amount"
|
||||||
type="number"
|
type="number"
|
||||||
|
min="0"
|
||||||
variant="filled"
|
variant="filled"
|
||||||
required
|
required
|
||||||
error={invalid}
|
error={invalid}
|
||||||
@ -474,7 +486,7 @@ export function DestinationSelectionSendCash({
|
|||||||
}
|
}
|
||||||
value={amount}
|
value={amount}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setAmount(e);
|
positiveSetAmount(e);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -19,6 +19,7 @@ import { styled } from "@linaria/react";
|
|||||||
import { Fragment, h, VNode } from "preact";
|
import { Fragment, h, VNode } from "preact";
|
||||||
import { useState } from "preact/hooks";
|
import { useState } from "preact/hooks";
|
||||||
import { Amount } from "../../components/Amount.js";
|
import { Amount } from "../../components/Amount.js";
|
||||||
|
import { ErrorMessage } from "../../components/ErrorMessage.js";
|
||||||
import { LoadingError } from "../../components/LoadingError.js";
|
import { LoadingError } from "../../components/LoadingError.js";
|
||||||
import { SelectList } from "../../components/SelectList.js";
|
import { SelectList } from "../../components/SelectList.js";
|
||||||
import { Input, SvgIcon } from "../../components/styled/index.js";
|
import { Input, SvgIcon } from "../../components/styled/index.js";
|
||||||
@ -156,17 +157,16 @@ export function NoExchangesView({
|
|||||||
const { i18n } = useTranslationContext();
|
const { i18n } = useTranslationContext();
|
||||||
if (!currency) {
|
if (!currency) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<ErrorMessage
|
||||||
<i18n.Translate>could not find any exchange</i18n.Translate>
|
title={<i18n.Translate>Could not find any exchange</i18n.Translate>}
|
||||||
</div>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div>
|
<ErrorMessage
|
||||||
<i18n.Translate>
|
title={<i18n.Translate>Could not find any exchange for the currency {currency}</i18n.Translate>}
|
||||||
could not find any exchange for the currency {currency}
|
/>
|
||||||
</i18n.Translate>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user