From 8b31b63e1ea26d6e58a54ab4fa6ee7ce24fe41d2 Mon Sep 17 00:00:00 2001 From: Vasek Mlejnsky Date: Wed, 29 Aug 2018 11:33:31 +0200 Subject: [PATCH] Refactorize AccountSummary --- .../Wallet/views/AccountSummary/index.js | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/views/Wallet/views/AccountSummary/index.js b/src/views/Wallet/views/AccountSummary/index.js index 59727715..2f067fd5 100644 --- a/src/views/Wallet/views/AccountSummary/index.js +++ b/src/views/Wallet/views/AccountSummary/index.js @@ -4,7 +4,10 @@ import React from 'react'; import { H2 } from 'components/Heading'; import TooltipContent from 'components/TooltipContent'; import BigNumber from 'bignumber.js'; -import { Async as AsyncSelect } from 'react-select'; +import Icon from 'components/Icon'; +import { AsyncSelect } from 'components/Select'; +import ICONS from 'config/icons'; +import colors from 'config/colors'; import Tooltip from 'rc-tooltip'; import CoinLogo from 'components/CoinLogo'; @@ -44,6 +47,10 @@ const StyledIcon = styled(Icon)` } `; +const AsyncSelectWrapper = styled.div` + padding: 0px 48px 32px 48px; +`; + const Summary = (props: Props) => { const device = props.wallet.selectedDevice; const { @@ -56,15 +63,10 @@ const Summary = (props: Props) => { // flow if (!device || !account || !network) return null; - const tokensTooltip = ( - - Insert token name, symbol or address to be able to send it. - - ); const explorerLink: string = `${network.explorer.address}${account.address}`; - const pendingAmount: BigNumber = stateUtils.getPendingAmount(pending, network.symbol); const balance: string = new BigNumber(account.balance).minus(pendingAmount).toString(10); + return ( @@ -95,7 +97,11 @@ const Summary = (props: Props) => { Tokens } - overlay={tokensTooltip} + overlay={( + + Insert token name, symbol or address to be able to send it. + + )} placement="top" > { {/* 0x58cda554935e4a1f2acbe15f8757400af275e084 Lahod */} {/* 0x58cda554935e4a1f2acbe15f8757400af275e084 T01 */} -
+ + {/* TOOO: AsyncSelect is lagging when dropdown menu must show more than 200 items */} + {/* TODO: Input's box-shadow */} + 'Loading...'} + noOptionsMessage={() => 'Token not found'} onChange={token => props.addToken(token, account)} loadOptions={input => props.loadTokens(input, account.network)} - filterOptions={ - (options: Array, search: string, values: Array) => options.map((o) => { - const added = tokens.find(t => t.symbol === o.symbol); - if (added) { - return { - ...o, - name: `${o.name} (Already added)`, - disabled: true, - }; - } - return o; - }) - } - valueKey="symbol" - labelKey="name" - placeholder="Search for token" - searchPromptText="Type token name or address" - noResultsText="Token not found" + formatOptionLabel={(option) => { + const isAdded = tokens.find(t => t.symbol === option.symbol); + if (isAdded) { + return `${option.name} (Already added)`; + } + return option.name; + }} + getOptionLabel={option => option.name} + getOptionValue={option => option.symbol} /> - -
+