mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
36be38e979
* Updating import paths for Text component * Updating snapshots * Adding story for TokenCell * Updating banner in account details * Fixing lint issue by removing unused import
71 lines
1.8 KiB
JavaScript
71 lines
1.8 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import {
|
|
BannerAlert,
|
|
ButtonIcon,
|
|
ButtonPrimary,
|
|
IconName,
|
|
Box,
|
|
Text,
|
|
} from '../../component-library';
|
|
|
|
import {
|
|
AlignItems,
|
|
BorderColor,
|
|
BorderRadius,
|
|
Display,
|
|
FlexDirection,
|
|
Severity,
|
|
TextVariant,
|
|
} from '../../../helpers/constants/design-system';
|
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
|
import { useCopyToClipboard } from '../../../hooks/useCopyToClipboard';
|
|
|
|
export const AccountDetailsKey = ({ accountName, onClose, privateKey }) => {
|
|
const t = useI18nContext();
|
|
|
|
const [privateKeyCopied, handlePrivateKeyCopy] = useCopyToClipboard();
|
|
|
|
return (
|
|
<>
|
|
<Text
|
|
marginTop={6}
|
|
variant={TextVariant.bodySm}
|
|
style={{ wordBreak: 'break-word' }}
|
|
>
|
|
{t('privateKeyCopyWarning', [accountName])}
|
|
</Text>
|
|
<Box
|
|
display={Display.Flex}
|
|
flexDirection={FlexDirection.Row}
|
|
alignItems={AlignItems.center}
|
|
borderRadius={BorderRadius.SM}
|
|
borderWidth={1}
|
|
borderColor={BorderColor.default}
|
|
padding={4}
|
|
gap={4}
|
|
>
|
|
<Text variant={TextVariant.bodySm} style={{ wordBreak: 'break-word' }}>
|
|
{privateKey}
|
|
</Text>
|
|
<ButtonIcon
|
|
onClick={() => handlePrivateKeyCopy(privateKey)}
|
|
iconName={privateKeyCopied ? IconName.CopySuccess : IconName.Copy}
|
|
/>
|
|
</Box>
|
|
<BannerAlert severity={Severity.Danger} marginTop={4}>
|
|
<Text variant={TextVariant.bodySm}>{t('privateKeyWarning')}</Text>
|
|
</BannerAlert>
|
|
<ButtonPrimary marginTop={6} onClick={onClose} block>
|
|
{t('done')}
|
|
</ButtonPrimary>
|
|
</>
|
|
);
|
|
};
|
|
|
|
AccountDetailsKey.propTypes = {
|
|
accountName: PropTypes.string.isRequired,
|
|
onClose: PropTypes.func.isRequired,
|
|
privateKey: PropTypes.string.isRequired,
|
|
};
|