You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
3.0 KiB
100 lines
3.0 KiB
4 years ago
|
import React from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import { Redirect } from 'react-router-dom';
|
||
4 years ago
|
|
||
4 years ago
|
import Identicon from '../../../../components/ui/identicon';
|
||
|
import Copy from '../../../../components/ui/icon/copy-icon.component';
|
||
|
import Button from '../../../../components/ui/button/button.component';
|
||
4 years ago
|
|
||
4 years ago
|
import Tooltip from '../../../../components/ui/tooltip';
|
||
|
import { useI18nContext } from '../../../../hooks/useI18nContext';
|
||
|
import { useCopyToClipboard } from '../../../../hooks/useCopyToClipboard';
|
||
5 years ago
|
|
||
4 years ago
|
function quadSplit(address) {
|
||
|
return `0x ${address
|
||
|
.slice(2)
|
||
|
.match(/.{1,4}/gu)
|
||
4 years ago
|
.join(' ')}`;
|
||
5 years ago
|
}
|
||
|
|
||
4 years ago
|
function ViewContact({
|
||
4 years ago
|
history,
|
||
|
name,
|
||
|
address,
|
||
|
checkSummedAddress,
|
||
|
memo,
|
||
|
editRoute,
|
||
|
listRoute,
|
||
|
}) {
|
||
4 years ago
|
const t = useI18nContext();
|
||
|
const [copied, handleCopy] = useCopyToClipboard();
|
||
5 years ago
|
|
||
4 years ago
|
if (!address) {
|
||
4 years ago
|
return <Redirect to={{ pathname: listRoute }} />;
|
||
5 years ago
|
}
|
||
|
|
||
4 years ago
|
return (
|
||
|
<div className="settings-page__content-row">
|
||
|
<div className="settings-page__content-item">
|
||
|
<div className="settings-page__header address-book__header">
|
||
|
<Identicon address={address} diameter={60} />
|
||
|
<div className="address-book__header__name">{name}</div>
|
||
|
</div>
|
||
|
<div className="address-book__view-contact__group">
|
||
|
<Button
|
||
|
type="secondary"
|
||
|
onClick={() => {
|
||
4 years ago
|
history.push(`${editRoute}/${address}`);
|
||
4 years ago
|
}}
|
||
|
>
|
||
|
{t('edit')}
|
||
|
</Button>
|
||
|
</div>
|
||
|
<div className="address-book__view-contact__group">
|
||
|
<div className="address-book__view-contact__group__label">
|
||
|
{t('ethereumPublicAddress')}
|
||
5 years ago
|
</div>
|
||
4 years ago
|
<div className="address-book__view-contact__group__value">
|
||
|
<div className="address-book__view-contact__group__static-address">
|
||
|
{quadSplit(checkSummedAddress)}
|
||
5 years ago
|
</div>
|
||
4 years ago
|
<Tooltip
|
||
|
position="bottom"
|
||
|
title={copied ? t('copiedExclamation') : t('copyToClipboard')}
|
||
|
>
|
||
5 years ago
|
<button
|
||
5 years ago
|
className="address-book__view-contact__group__static-address--copy-icon"
|
||
4 years ago
|
onClick={() => {
|
||
4 years ago
|
handleCopy(checkSummedAddress);
|
||
4 years ago
|
}}
|
||
5 years ago
|
>
|
||
|
<Copy size={20} color="#3098DC" />
|
||
|
</button>
|
||
4 years ago
|
</Tooltip>
|
||
5 years ago
|
</div>
|
||
4 years ago
|
</div>
|
||
|
<div className="address-book__view-contact__group">
|
||
|
<div className="address-book__view-contact__group__label--capitalized">
|
||
|
{t('memo')}
|
||
|
</div>
|
||
|
<div className="address-book__view-contact__group__static-address">
|
||
|
{memo}
|
||
5 years ago
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
4 years ago
|
</div>
|
||
4 years ago
|
);
|
||
5 years ago
|
}
|
||
4 years ago
|
|
||
|
ViewContact.propTypes = {
|
||
|
name: PropTypes.string,
|
||
|
address: PropTypes.string,
|
||
|
history: PropTypes.object,
|
||
|
checkSummedAddress: PropTypes.string,
|
||
|
memo: PropTypes.string,
|
||
|
editRoute: PropTypes.string,
|
||
|
listRoute: PropTypes.string.isRequired,
|
||
4 years ago
|
};
|
||
4 years ago
|
|
||
4 years ago
|
export default React.memo(ViewContact);
|