fix: added missing lodash dependency to accounts lib

fix: show full languages name on the dropdown

fix: search crypto per name as well

fix: limit selected languages to 4 (the same as the old admin)

fix: removed duplicated import
This commit is contained in:
Liordino Neto 2020-07-03 18:06:11 -03:00 committed by Josh Harvey
parent f641e605a4
commit 994f823632
3 changed files with 16 additions and 6 deletions

View file

@ -1,6 +1,5 @@
const _ = require('lodash/fp') const _ = require('lodash/fp')
const { COINS, ALL_CRYPTOS } = require('./coins') const { COINS, ALL_CRYPTOS } = require('./coins')
const _ = require('lodash/fp')
const { BTC, BCH, DASH, ETH, LTC, ZEC } = COINS const { BTC, BCH, DASH, ETH, LTC, ZEC } = COINS

View file

@ -1,10 +1,12 @@
import { useFormikContext } from 'formik' import { useFormikContext } from 'formik'
import * as R from 'ramda' import * as R from 'ramda'
import React from 'react' import React, { useState } from 'react'
import { Autocomplete } from '../base' import { Autocomplete } from '../base'
const AutocompleteFormik = ({ options, ...props }) => { const AutocompleteFormik = ({ options, ...props }) => {
const [open, setOpen] = useState(false)
const { name, onBlur, value } = props.field const { name, onBlur, value } = props.field
const { touched, errors, setFieldValue } = props.form const { touched, errors, setFieldValue } = props.form
const error = !!(touched[name] && errors[name]) const error = !!(touched[name] && errors[name])
@ -20,7 +22,10 @@ const AutocompleteFormik = ({ options, ...props }) => {
onBlur={onBlur} onBlur={onBlur}
value={value} value={value}
error={error} error={error}
open={open}
options={innerOptions} options={innerOptions}
onOpen={() => setOpen(value.length !== props.limit)}
onClose={() => setOpen(false)}
{...props} {...props}
/> />
) )

View file

@ -1,8 +1,11 @@
import { createFilterOptions } from '@material-ui/lab/Autocomplete'
import * as R from 'ramda' import * as R from 'ramda'
import * as Yup from 'yup' import * as Yup from 'yup'
import Autocomplete from 'src/components/inputs/formik/Autocomplete.js' import Autocomplete from 'src/components/inputs/formik/Autocomplete.js'
const LANGUAGE_SELECTION_LIMIT = 4
const getFields = (getData, names) => { const getFields = (getData, names) => {
return R.filter(it => R.includes(it.name, names), allFields(getData)) return R.filter(it => R.includes(it.name, names), allFields(getData))
} }
@ -28,7 +31,6 @@ const allFields = getData => {
const currencyData = getData(['currencies']) const currencyData = getData(['currencies'])
const languageData = getData(['languages']) const languageData = getData(['languages'])
const cryptoData = getData(['cryptoCurrencies']) const cryptoData = getData(['cryptoCurrencies'])
return [ return [
{ {
name: 'machine', name: 'machine',
@ -76,8 +78,9 @@ const allFields = getData => {
inputProps: { inputProps: {
options: languageData, options: languageData,
valueProp: 'code', valueProp: 'code',
getLabel: R.path(['code']), getLabel: R.path(['display']),
multiple: true multiple: true,
limit: LANGUAGE_SELECTION_LIMIT
} }
}, },
{ {
@ -90,7 +93,10 @@ const allFields = getData => {
options: cryptoData, options: cryptoData,
valueProp: 'code', valueProp: 'code',
getLabel: R.path(['code']), getLabel: R.path(['code']),
multiple: true multiple: true,
filterOptions: createFilterOptions({
stringify: option => `${option.code} ${option.display}`
})
} }
} }
] ]