2021-06-03 18:08:37 +02:00
|
|
|
import React, { useContext } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { I18nContext } from '../../../contexts/i18n';
|
|
|
|
import UrlIcon from '../../../components/ui/url-icon';
|
|
|
|
import Popover from '../../../components/ui/popover';
|
|
|
|
import Button from '../../../components/ui/button';
|
|
|
|
import Box from '../../../components/ui/box';
|
2023-04-07 17:48:30 +02:00
|
|
|
import { Text } from '../../../components/component-library';
|
2021-07-02 21:07:56 +02:00
|
|
|
import ActionableMessage from '../../../components/ui/actionable-message/actionable-message';
|
2021-06-03 18:08:37 +02:00
|
|
|
import {
|
2023-04-07 17:48:30 +02:00
|
|
|
TextVariant,
|
2021-06-03 18:08:37 +02:00
|
|
|
FONT_WEIGHT,
|
2023-02-02 21:15:26 +01:00
|
|
|
AlignItems,
|
2021-06-03 18:08:37 +02:00
|
|
|
DISPLAY,
|
|
|
|
} from '../../../helpers/constants/design-system';
|
|
|
|
|
|
|
|
export default function ImportToken({
|
|
|
|
onImportTokenCloseClick,
|
|
|
|
onImportTokenClick,
|
|
|
|
setIsImportTokenModalOpen,
|
|
|
|
tokenForImport,
|
|
|
|
}) {
|
|
|
|
const t = useContext(I18nContext);
|
|
|
|
const ImportTokenModalFooter = (
|
|
|
|
<>
|
|
|
|
<Button
|
|
|
|
type="secondary"
|
|
|
|
className="page-container__footer-button"
|
|
|
|
onClick={onImportTokenCloseClick}
|
|
|
|
>
|
|
|
|
{t('cancel')}
|
|
|
|
</Button>
|
|
|
|
<Button
|
2021-10-05 21:20:42 +02:00
|
|
|
type="primary"
|
2021-06-03 18:08:37 +02:00
|
|
|
className="page-container__footer-button"
|
|
|
|
onClick={onImportTokenClick}
|
2022-10-28 16:09:46 +02:00
|
|
|
data-testid="page-container__import-button"
|
2021-06-03 18:08:37 +02:00
|
|
|
>
|
|
|
|
{t('import')}
|
|
|
|
</Button>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Popover
|
|
|
|
title={t('importTokenQuestion')}
|
|
|
|
onClose={() => setIsImportTokenModalOpen(false)}
|
|
|
|
footer={ImportTokenModalFooter}
|
|
|
|
>
|
|
|
|
<Box
|
2022-07-20 22:47:51 +02:00
|
|
|
paddingRight={6}
|
|
|
|
paddingBottom={4}
|
|
|
|
paddingLeft={4}
|
2023-02-02 21:15:26 +01:00
|
|
|
alignItems={AlignItems.center}
|
2021-06-03 18:08:37 +02:00
|
|
|
display={DISPLAY.FLEX}
|
|
|
|
className="import-token"
|
|
|
|
>
|
|
|
|
<ActionableMessage type="danger" message={t('importTokenWarning')} />
|
|
|
|
<UrlIcon
|
|
|
|
url={tokenForImport.iconUrl}
|
|
|
|
className="import-token__token-icon"
|
|
|
|
fallbackClassName="import-token__token-icon"
|
|
|
|
name={tokenForImport.symbol}
|
|
|
|
/>
|
2023-04-07 17:48:30 +02:00
|
|
|
<Text
|
|
|
|
variant={TextVariant.headingSm}
|
|
|
|
as="h4"
|
2021-06-03 18:08:37 +02:00
|
|
|
fontWeight={FONT_WEIGHT.BOLD}
|
2023-04-07 17:48:30 +02:00
|
|
|
marginTop={2}
|
|
|
|
marginBottom={3}
|
2021-06-03 18:08:37 +02:00
|
|
|
>
|
2022-11-03 14:54:49 +01:00
|
|
|
{tokenForImport.name || ''}
|
2023-04-07 17:48:30 +02:00
|
|
|
</Text>
|
|
|
|
<Text variant={TextVariant.bodySm} as="h6">
|
|
|
|
{t('contract')}:
|
|
|
|
</Text>
|
|
|
|
<Text
|
|
|
|
variant={TextVariant.bodySm}
|
2021-06-03 18:08:37 +02:00
|
|
|
className="import-token__contract-address"
|
2023-04-07 17:48:30 +02:00
|
|
|
as="h6"
|
|
|
|
marginBottom={6}
|
2021-06-03 18:08:37 +02:00
|
|
|
>
|
2022-11-03 14:54:49 +01:00
|
|
|
{tokenForImport.address || ''}
|
2023-04-07 17:48:30 +02:00
|
|
|
</Text>
|
2021-06-03 18:08:37 +02:00
|
|
|
</Box>
|
|
|
|
</Popover>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
ImportToken.propTypes = {
|
|
|
|
onImportTokenCloseClick: PropTypes.func,
|
|
|
|
onImportTokenClick: PropTypes.func,
|
|
|
|
setIsImportTokenModalOpen: PropTypes.func,
|
|
|
|
tokenForImport: PropTypes.object,
|
|
|
|
};
|