|
|
@ -1,10 +1,17 @@ |
|
|
|
import React from 'react' |
|
|
|
import React, { useMemo } from 'react' |
|
|
|
import PropTypes from 'prop-types' |
|
|
|
import PropTypes from 'prop-types' |
|
|
|
import classnames from 'classnames' |
|
|
|
import classnames from 'classnames' |
|
|
|
import Identicon from '../../ui/identicon' |
|
|
|
import Identicon from '../../ui/identicon' |
|
|
|
import ListItem from '../../ui/list-item' |
|
|
|
import ListItem from '../../ui/list-item' |
|
|
|
import Tooltip from '../../ui/tooltip-v2' |
|
|
|
import Tooltip from '../../ui/tooltip-v2' |
|
|
|
import InfoIcon from '../../ui/icon/info-icon.component' |
|
|
|
import InfoIcon from '../../ui/icon/info-icon.component' |
|
|
|
|
|
|
|
import Button from '../../ui/button' |
|
|
|
|
|
|
|
import { useI18nContext } from '../../../hooks/useI18nContext' |
|
|
|
|
|
|
|
import { useMetricEvent } from '../../../hooks/useMetricEvent' |
|
|
|
|
|
|
|
import { useDispatch } from 'react-redux' |
|
|
|
|
|
|
|
import { updateSendToken } from '../../../store/actions' |
|
|
|
|
|
|
|
import { useHistory } from 'react-router-dom' |
|
|
|
|
|
|
|
import { SEND_ROUTE } from '../../../helpers/constants/routes' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const AssetListItem = ({ |
|
|
|
const AssetListItem = ({ |
|
|
@ -13,11 +20,23 @@ const AssetListItem = ({ |
|
|
|
iconClassName, |
|
|
|
iconClassName, |
|
|
|
onClick, |
|
|
|
onClick, |
|
|
|
tokenAddress, |
|
|
|
tokenAddress, |
|
|
|
|
|
|
|
tokenSymbol, |
|
|
|
|
|
|
|
tokenDecimals, |
|
|
|
tokenImage, |
|
|
|
tokenImage, |
|
|
|
warning, |
|
|
|
warning, |
|
|
|
primary, |
|
|
|
primary, |
|
|
|
secondary, |
|
|
|
secondary, |
|
|
|
}) => { |
|
|
|
}) => { |
|
|
|
|
|
|
|
const t = useI18nContext() |
|
|
|
|
|
|
|
const dispatch = useDispatch() |
|
|
|
|
|
|
|
const history = useHistory() |
|
|
|
|
|
|
|
const sendTokenEvent = useMetricEvent({ |
|
|
|
|
|
|
|
eventOpts: { |
|
|
|
|
|
|
|
category: 'Navigation', |
|
|
|
|
|
|
|
action: 'Home', |
|
|
|
|
|
|
|
name: 'Clicked Send: Token', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}) |
|
|
|
const titleIcon = warning |
|
|
|
const titleIcon = warning |
|
|
|
? ( |
|
|
|
? ( |
|
|
|
<Tooltip |
|
|
|
<Tooltip |
|
|
@ -40,6 +59,38 @@ const AssetListItem = ({ |
|
|
|
) |
|
|
|
) |
|
|
|
: null |
|
|
|
: null |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const sendTokenButton = useMemo(() => { |
|
|
|
|
|
|
|
if (tokenAddress == null) { |
|
|
|
|
|
|
|
return null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
<Button |
|
|
|
|
|
|
|
type="link" |
|
|
|
|
|
|
|
className="asset-list-item__send-token-button" |
|
|
|
|
|
|
|
onClick={(e) => { |
|
|
|
|
|
|
|
e.stopPropagation() |
|
|
|
|
|
|
|
sendTokenEvent() |
|
|
|
|
|
|
|
dispatch(updateSendToken({ |
|
|
|
|
|
|
|
address: tokenAddress, |
|
|
|
|
|
|
|
decimals: tokenDecimals, |
|
|
|
|
|
|
|
symbol: tokenSymbol, |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
history.push(SEND_ROUTE) |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{t('sendSpecifiedTokens', [tokenSymbol])} |
|
|
|
|
|
|
|
</Button> |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}, [ |
|
|
|
|
|
|
|
tokenSymbol, |
|
|
|
|
|
|
|
sendTokenEvent, |
|
|
|
|
|
|
|
tokenAddress, |
|
|
|
|
|
|
|
tokenDecimals, |
|
|
|
|
|
|
|
history, |
|
|
|
|
|
|
|
t, |
|
|
|
|
|
|
|
dispatch, |
|
|
|
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<ListItem |
|
|
|
<ListItem |
|
|
|
className={classnames('asset-list-item', className)} |
|
|
|
className={classnames('asset-list-item', className)} |
|
|
@ -57,7 +108,12 @@ const AssetListItem = ({ |
|
|
|
/> |
|
|
|
/> |
|
|
|
)} |
|
|
|
)} |
|
|
|
midContent={midContent} |
|
|
|
midContent={midContent} |
|
|
|
rightContent={<i className="fas fa-chevron-right asset-list-item__chevron-right" />} |
|
|
|
rightContent={( |
|
|
|
|
|
|
|
<> |
|
|
|
|
|
|
|
<i className="fas fa-chevron-right asset-list-item__chevron-right" /> |
|
|
|
|
|
|
|
{sendTokenButton} |
|
|
|
|
|
|
|
</> |
|
|
|
|
|
|
|
)} |
|
|
|
/> |
|
|
|
/> |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
@ -68,6 +124,8 @@ AssetListItem.propTypes = { |
|
|
|
iconClassName: PropTypes.string, |
|
|
|
iconClassName: PropTypes.string, |
|
|
|
onClick: PropTypes.func.isRequired, |
|
|
|
onClick: PropTypes.func.isRequired, |
|
|
|
tokenAddress: PropTypes.string, |
|
|
|
tokenAddress: PropTypes.string, |
|
|
|
|
|
|
|
tokenSymbol: PropTypes.string, |
|
|
|
|
|
|
|
tokenDecimals: PropTypes.number, |
|
|
|
tokenImage: PropTypes.string, |
|
|
|
tokenImage: PropTypes.string, |
|
|
|
warning: PropTypes.node, |
|
|
|
warning: PropTypes.node, |
|
|
|
primary: PropTypes.string, |
|
|
|
primary: PropTypes.string, |
|
|
|