fix: allow only positive integers on threshold input
This commit is contained in:
parent
7551a50c23
commit
67090b2cc7
1 changed files with 15 additions and 2 deletions
|
|
@ -14,6 +14,7 @@ const useStyles = makeStyles(mainStyles)
|
|||
const SelectTriggerType = ({ fiatCurrencyCode }) => {
|
||||
const [helpPopperAnchorEl, setHelpPopperAnchorEl] = useState(null)
|
||||
const [radioGroupValue, setRadioGroupValue] = useState('amount')
|
||||
const [thresholdValue, setThresholdValue] = useState('')
|
||||
|
||||
const classes = useStyles()
|
||||
|
||||
|
|
@ -29,6 +30,12 @@ const SelectTriggerType = ({ fiatCurrencyCode }) => {
|
|||
setRadioGroupValue(newValue)
|
||||
}
|
||||
|
||||
const validateThresholdInputIsPositiveInteger = value => {
|
||||
if (parseFloat(value) === value >>> 0 && !value.includes('.')) {
|
||||
setThresholdValue(value)
|
||||
}
|
||||
}
|
||||
|
||||
const helpPopperOpen = Boolean(helpPopperAnchorEl)
|
||||
|
||||
const radioButtonOptions = [
|
||||
|
|
@ -74,8 +81,14 @@ const SelectTriggerType = ({ fiatCurrencyCode }) => {
|
|||
</div>
|
||||
<H4>Threshold</H4>
|
||||
<div className={classes.rowWrapper}>
|
||||
{/* TODO: allow only monetary values */}
|
||||
<TextInput large className={classes.textInput} />
|
||||
<TextInput
|
||||
className={classes.textInput}
|
||||
onChange={event =>
|
||||
validateThresholdInputIsPositiveInteger(event.target.value)
|
||||
}
|
||||
large
|
||||
value={thresholdValue}
|
||||
/>
|
||||
<TL1>{fiatCurrencyCode}</TL1>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue