import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
import { useI18nContext } from '../../../../hooks/useI18nContext';
import { MetaMetricsContext } from '../../../../contexts/metametrics';
import {
MetaMetricsEventCategory,
MetaMetricsEventName,
MetaMetricsTokenEventSource,
} from '../../../../../shared/constants/metametrics';
import { getDetectedTokensInCurrentNetwork } from '../../../../selectors';
import Popover from '../../../ui/popover';
import Box from '../../../ui/box';
import Button from '../../../ui/button';
import DetectedTokenDetails from '../detected-token-details/detected-token-details';
const DetectedTokenSelectionPopover = ({
tokensListDetected,
handleTokenSelection,
onImport,
onIgnoreAll,
setShowDetectedTokens,
sortingBasedOnTokenSelection,
}) => {
const t = useI18nContext();
const trackEvent = useContext(MetaMetricsContext);
const detectedTokens = useSelector(getDetectedTokensInCurrentNetwork);
const { selected: selectedTokens = [] } =
sortingBasedOnTokenSelection(tokensListDetected);
const numOfTokensImporting =
selectedTokens.length === detectedTokens.length
? `All`
: `(${selectedTokens.length})`;
const onClose = () => {
setShowDetectedTokens(false);
const eventTokensDetails = detectedTokens.map(
({ address, symbol }) => `${symbol} - ${address}`,
);
trackEvent({
event: MetaMetricsEventName.TokenImportCanceled,
category: MetaMetricsEventCategory.Wallet,
properties: {
source: MetaMetricsTokenEventSource.Detected,
tokens: eventTokensDetails,
},
});
};
const footer = (
<>
>
);
return (
{detectedTokens.map((token, index) => {
return (
);
})}
);
};
DetectedTokenSelectionPopover.propTypes = {
tokensListDetected: PropTypes.object,
handleTokenSelection: PropTypes.func.isRequired,
onIgnoreAll: PropTypes.func.isRequired,
onImport: PropTypes.func.isRequired,
setShowDetectedTokens: PropTypes.func.isRequired,
sortingBasedOnTokenSelection: PropTypes.func.isRequired,
};
export default DetectedTokenSelectionPopover;