Browse Source

Fix AddAccount modal SelectCurrency component

master
meriadec 7 years ago
parent
commit
e40ccf1811
No known key found for this signature in database GPG Key ID: 1D2FC2305E2CB399
  1. 5
      src/components/SelectCurrency/index.js
  2. 22
      src/components/modals/AddAccount/01-step-currency.js

5
src/components/SelectCurrency/index.js

@ -32,10 +32,11 @@ const currencies = listCryptoCurrencies().sort((a, b) => a.name.localeCompare(b.
type Props = { type Props = {
onChange: Function, onChange: Function,
value?: CryptoCurrency, value?: CryptoCurrency,
placeholder: string,
t: T, t: T,
} }
const SelectCurrency = ({ onChange, value, t, ...props }: Props) => ( const SelectCurrency = ({ onChange, value, t, placeholder, ...props }: Props) => (
<Select <Select
{...props} {...props}
value={value} value={value}
@ -43,7 +44,7 @@ const SelectCurrency = ({ onChange, value, t, ...props }: Props) => (
renderItem={renderItem} renderItem={renderItem}
keyProp="id" keyProp="id"
items={currencies} items={currencies}
placeholder={t('common:selectCurrency')} placeholder={placeholder || t('common:selectCurrency')}
fontSize={4} fontSize={4}
onChange={onChange} onChange={onChange}
/> />

22
src/components/modals/AddAccount/01-step-currency.js

@ -2,22 +2,12 @@
import React from 'react' import React from 'react'
import { listCryptoCurrencies } from '@ledgerhq/live-common/lib/helpers/currencies'
import type { CryptoCurrency } from '@ledgerhq/live-common/lib/types' import type { CryptoCurrency } from '@ledgerhq/live-common/lib/types'
import type { T } from 'types/common' import type { T } from 'types/common'
import get from 'lodash/get'
import Box from 'components/base/Box' import Box from 'components/base/Box'
import Label from 'components/base/Label' import Label from 'components/base/Label'
import Select from 'components/base/Select' import SelectCurrency from 'components/SelectCurrency'
const currencies = listCryptoCurrencies().map(currency => ({
key: currency.id,
name: currency.name,
data: currency,
}))
type Props = { type Props = {
onChangeCurrency: Function, onChangeCurrency: Function,
@ -28,14 +18,10 @@ type Props = {
export default (props: Props) => ( export default (props: Props) => (
<Box flow={1}> <Box flow={1}>
<Label>{props.t('common:currency')}</Label> <Label>{props.t('common:currency')}</Label>
<Select <SelectCurrency
placeholder={props.t('common:chooseWalletPlaceholder')} placeholder={props.t('common:chooseWalletPlaceholder')}
onChange={item => props.onChangeCurrency(item.data)} onChange={props.onChangeCurrency}
renderSelected={item => item.name} value={props.currency}
items={currencies}
value={
props.currency ? currencies.find(c => c.key === get(props, 'currency.coinType')) : null
}
/> />
</Box> </Box>
) )

Loading…
Cancel
Save