1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 12:29:06 +01:00
metamask-extension/ui/components/multichain/import-tokens-modal/import-tokens-modal-confirm.js
David Walsh ee4bf2d264
Fix #19829: UX: Multichain: Move "Import Tokens" to Modal (#19553)
* Move Import Tokens to Modal

* Better dimensions for long token name

* Add padding above tabs
2023-08-14 11:08:59 -05:00

109 lines
3.3 KiB
JavaScript

import React from 'react';
import { useSelector } from 'react-redux';
import PropTypes from 'prop-types';
import {
Box,
ButtonPrimary,
ButtonSecondary,
Text,
} from '../../component-library';
import {
AlignItems,
Display,
Size,
TextAlign,
TextColor,
TextVariant,
} from '../../../helpers/constants/design-system';
import TokenBalance from '../../ui/token-balance/token-balance';
import Identicon from '../../ui/identicon';
import { useI18nContext } from '../../../hooks/useI18nContext';
import { getPendingTokens } from '../../../ducks/metamask/metamask';
export const ImportTokensModalConfirm = ({ onBackClick, onImportClick }) => {
const t = useI18nContext();
const pendingTokens = useSelector(getPendingTokens);
return (
<Box paddingTop={4} paddingBottom={4}>
<Text textAlign={TextAlign.Center}>{t('likeToImportTokens')}</Text>
<Box marginTop={4} marginBottom={4}>
<Box display={Display.Flex}>
<Text
variant={TextVariant.bodySm}
className="import-tokens-modal__token-name"
>
{t('token')}
</Text>
<Text
variant={TextVariant.bodySm}
className="import-tokens-modal__token-balance"
>
{t('balance')}
</Text>
</Box>
<Box
display={Display.Flex}
className="import-tokens-modal__confirm-token-list"
>
{Object.entries(pendingTokens).map(([address, token]) => {
const { name, symbol } = token;
return (
<Box
key={address}
marginBottom={4}
display={Display.Flex}
className="import-tokens-modal__confirm-token-list-item"
>
<Box
display={Display.Flex}
alignItems={AlignItems.center}
className="import-tokens-modal__confirm-token-list-item-wrapper"
>
<Identicon diameter={36} address={address} />
<Box
marginInlineStart={4}
className="import-tokens-modal__confirm-token-list-item-wrapper__text"
>
<Text ellipsis>{name}</Text>
<Text
variant={TextVariant.bodySm}
color={TextColor.textAlternative}
>
{symbol}
</Text>
</Box>
</Box>
<Box
className="import-tokens-modal__token-balance"
alignItems={AlignItems.flexStart}
>
<TokenBalance token={token} />
</Box>
</Box>
);
})}
</Box>
<Box display={Display.Flex} gap={2} marginTop={4}>
<ButtonSecondary size={Size.LG} onClick={onBackClick} block>
{t('back')}
</ButtonSecondary>
<ButtonPrimary
size={Size.LG}
onClick={onImportClick}
block
data-testid="import-tokens-modal-import-button"
>
{t('import')}
</ButtonPrimary>
</Box>
</Box>
</Box>
);
};
ImportTokensModalConfirm.propTypes = {
onBackClick: PropTypes.func.isRequired,
onImportClick: PropTypes.func.isRequired,
};