feat: use lamassu-coins to display crypto units options

This commit is contained in:
José Oliveira 2021-06-26 02:06:43 +01:00
parent 168257bcc4
commit 2ff160cc68
3 changed files with 17 additions and 12 deletions

View file

@ -32,13 +32,20 @@ const AdvancedWalletSchema = Yup.object().shape({
cryptoUnits: Yup.string().required()
})
const getAdvancedWalletElements = (cryptoCurrencies, config) => {
const getAdvancedWalletElements = (cryptoCurrencies, coinUtils) => {
const viewCryptoCurrency = it =>
R.compose(
R.prop(['display']),
R.find(R.propEq('code', it))
)(cryptoCurrencies)
const getOptions = R.curry((coinUtils, it) => {
const options = R.keys(coinUtils.getCryptoCurrency(it.id).units)
return R.map(option => {
return { code: option, display: option }
})(options)
})
return [
{
name: 'id',
@ -52,14 +59,10 @@ const getAdvancedWalletElements = (cryptoCurrencies, config) => {
name: 'cryptoUnits',
size: 'sm',
stripe: true,
view: it => it,
width: 190,
input: Autocomplete,
inputProps: {
options: [
{ code: 'mUnits', display: 'mUnits' },
{ code: 'fUnits', display: 'fUnits' }
],
options: getOptions(coinUtils),
valueProp: 'code',
labelProp: 'display'
}