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 = {
onChange: Function,
value?: CryptoCurrency,
placeholder: string,
t: T,
}
const SelectCurrency = ({ onChange, value, t, ...props }: Props) => (
const SelectCurrency = ({ onChange, value, t, placeholder, ...props }: Props) => (
<Select
{...props}
value={value}
@ -43,7 +44,7 @@ const SelectCurrency = ({ onChange, value, t, ...props }: Props) => (
renderItem={renderItem}
keyProp="id"
items={currencies}
placeholder={t('common:selectCurrency')}
placeholder={placeholder || t('common:selectCurrency')}
fontSize={4}
onChange={onChange}
/>

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

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

Loading…
Cancel
Save