import React, { useContext } from 'react'; import PropTypes from 'prop-types'; import { useSelector } from 'react-redux'; import classnames from 'classnames'; import { BlockSize, BorderColor, Display, FlexDirection, FontWeight, JustifyContent, TextColor, TextVariant, TextAlign, } from '../../../helpers/constants/design-system'; import { AvatarNetwork, AvatarNetworkSize, AvatarToken, BadgeWrapper, Box, Text, } from '../../component-library'; import { getCurrentChainId, getCurrentNetwork, getNativeCurrencyImage, getTestNetworkBackgroundColor, } from '../../../selectors'; import Tooltip from '../../ui/tooltip'; import { useI18nContext } from '../../../hooks/useI18nContext'; import { MetaMetricsContext } from '../../../contexts/metametrics'; import { MetaMetricsEventCategory, MetaMetricsEventName, } from '../../../../shared/constants/metametrics'; export const TokenListItem = ({ className, onClick, tokenSymbol, tokenImage, primary, secondary, title, }) => { const t = useI18nContext(); const primaryTokenImage = useSelector(getNativeCurrencyImage); const trackEvent = useContext(MetaMetricsContext); const chainId = useSelector(getCurrentChainId); // Used for badge icon const currentNetwork = useSelector(getCurrentNetwork); const testNetworkBackgroundColor = useSelector(getTestNetworkBackgroundColor); return ( { e.preventDefault(); onClick(); trackEvent({ category: MetaMetricsEventCategory.Tokens, event: MetaMetricsEventName.TokenDetailsOpened, properties: { location: 'Home', chain_id: chainId, token_symbol: tokenSymbol, }, }); }} > } marginRight={3} > {title === 'ETH' ? t('networkNameEthereum') : title} {secondary} {primary} {tokenSymbol}{' '} ); }; TokenListItem.propTypes = { /** * An additional className to apply to the TokenList. */ className: PropTypes.string, /** * The onClick handler to be passed to the TokenListItem component */ onClick: PropTypes.func, /** * tokenSymbol represents the symbol of the Token */ tokenSymbol: PropTypes.string, /** * title represents the name of the token and if name is not available then Symbol */ title: PropTypes.string, /** * tokenImage represnts the image of the token icon */ tokenImage: PropTypes.string, /** * primary represents the balance */ primary: PropTypes.string, /** * secondary represents the balance in dollars */ secondary: PropTypes.string, };