Feat: disable ETH 0-confLimit edit, in migrations make ETH 0-confLimit 0

This commit is contained in:
csrapr 2021-04-15 17:09:24 +01:00 committed by Josh Harvey
parent 23fc689f07
commit 84e7b67635
4 changed files with 33 additions and 13 deletions

View file

@ -3,8 +3,14 @@ import * as Yup from 'yup'
import { NumberInput } from 'src/components/inputs/formik'
import Autocomplete from 'src/components/inputs/formik/Autocomplete.js'
import { disabledColor } from 'src/styling/variables'
import { CURRENCY_MAX } from 'src/utils/constants'
const classes = {
editDisabled: {
color: disabledColor
}
}
const filterClass = type => R.filter(it => it.class === type)
const filterCoins = ({ id }) => R.filter(it => R.contains(id)(it.cryptos))
@ -21,13 +27,16 @@ const WalletSchema = Yup.object().shape({
})
const getElements = (cryptoCurrencies, accounts, onChange, wizard = false) => {
let currentCurrency = ''
const widthAdjust = wizard ? 11 : 0
const viewCryptoCurrency = it =>
R.compose(
const viewCryptoCurrency = it => {
const currencyDisplay = R.compose(
R.prop(['display']),
R.find(R.propEq('code', it))
)(cryptoCurrencies)
currentCurrency = currencyDisplay
return currencyDisplay
}
const filterOptions = type => filterClass(type)(accounts || [])
const getDisplayName = type => it =>
@ -40,6 +49,12 @@ const getElements = (cryptoCurrencies, accounts, onChange, wizard = false) => {
filterCoins(it)(filterOptions(option))
)
const getZeroConfLimit = it => {
if (currentCurrency === 'Ethereum')
return <div style={classes.editDisabled}>{it}</div>
return it
}
return [
{
name: 'id',
@ -112,12 +127,13 @@ const getElements = (cryptoCurrencies, accounts, onChange, wizard = false) => {
name: 'zeroConfLimit',
size: 'sm',
stripe: true,
view: it => it,
view: getZeroConfLimit,
input: NumberInput,
width: 190 - widthAdjust,
inputProps: {
decimalPlaces: 0
}
},
editable: row => row.id !== 'ETH'
}
]
}