import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import Identicon from '../../../ui/identicon'; import { ellipsify } from '../../../../pages/send/send.utils'; import Box from '../../../ui/box'; import { TextColor, TextVariant, } from '../../../../helpers/constants/design-system'; import { Text } from '../../../component-library'; function addressesEqual(address1, address2) { return String(address1).toLowerCase() === String(address2).toLowerCase(); } export default function RecipientGroup({ label, items, onSelect, selectedAddress, }) { if (!items || !items.length) { return null; } return ( {label && ( {label} )} {items.map(({ address, name }) => ( onSelect(address, name)} className={classnames({ 'send__select-recipient-wrapper__group-item': !addressesEqual( address, selectedAddress, ), 'send__select-recipient-wrapper__group-item--selected': addressesEqual(address, selectedAddress), })} padding={4} > {name || ellipsify(address)} {name && ( {ellipsify(address)} )} ))} ); } RecipientGroup.propTypes = { label: PropTypes.string, items: PropTypes.arrayOf( PropTypes.shape({ address: PropTypes.string.isRequired, name: PropTypes.string, }), ), onSelect: PropTypes.func.isRequired, selectedAddress: PropTypes.string, };