import React from 'react'; import PropTypes from 'prop-types'; import { Redirect } from 'react-router-dom'; import Identicon from '../../../../components/ui/identicon'; import Button from '../../../../components/ui/button/button.component'; import { ButtonIcon, ButtonIconSize, IconName, } from '../../../../components/component-library'; import Tooltip from '../../../../components/ui/tooltip'; import { useI18nContext } from '../../../../hooks/useI18nContext'; import { useCopyToClipboard } from '../../../../hooks/useCopyToClipboard'; import { IconColor } from '../../../../helpers/constants/design-system'; function quadSplit(address) { return `0x${address .slice(2) .match(/.{1,4}/gu) .join('')}`; } function ViewContact({ history, name, address, checkSummedAddress, memo, editRoute, listRoute, }) { const t = useI18nContext(); const [copied, handleCopy] = useCopyToClipboard(); if (!address) { return ; } return (
{name || address}
{t('ethereumPublicAddress')}
{quadSplit(checkSummedAddress)}
{ handleCopy(checkSummedAddress); }} iconName={copied ? IconName.CopySuccess : IconName.Copy} size={ButtonIconSize.Lg} color={IconColor.primaryDefault} />
{t('memo')}
{memo}
); } ViewContact.propTypes = { name: PropTypes.string, address: PropTypes.string, history: PropTypes.object, checkSummedAddress: PropTypes.string, memo: PropTypes.string, editRoute: PropTypes.string, listRoute: PropTypes.string.isRequired, }; export default React.memo(ViewContact);