import React, { useContext } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { useI18nContext } from '../../../hooks/useI18nContext'; import { MetaMetricsContext } from '../../../contexts/metametrics'; import { hideModal } from '../../../store/actions'; import { getSelectedAddress } from '../../../selectors/selectors'; import { toChecksumHexAddress } from '../../../../shared/modules/hexstring-utils'; import { Box, Button, Modal, ModalContent, ModalHeader, ModalOverlay, Text, } from '../../component-library'; import { BlockSize, BackgroundColor, Display, FlexWrap, FlexDirection, BorderRadius, FontWeight, TextAlign, AlignItems, } from '../../../helpers/constants/design-system'; import { MetaMetricsEventCategory, MetaMetricsEventName, } from '../../../../shared/constants/metametrics'; const InteractiveReplacementTokenModal = () => { const t = useI18nContext(); const trackEvent = useContext(MetaMetricsContext); const dispatch = useDispatch(); const { url } = useSelector( (state) => state.metamask.interactiveReplacementToken || {}, ); const { custodians } = useSelector( (state) => state.metamask.mmiConfiguration, ); const address = useSelector(getSelectedAddress); const custodyAccountDetails = useSelector( (state) => state.metamask.custodyAccountDetails[toChecksumHexAddress(address)], ); const custodianName = custodyAccountDetails?.custodianName; const custodian = custodians.find((item) => item.name === custodianName) || {}; const handleSubmit = () => { global.platform.openTab({ url, }); trackEvent({ category: MetaMetricsEventCategory.MMI, event: MetaMetricsEventName.InteractiveReplacementTokenButtonClicked, }); }; const handleClose = () => { dispatch(hideModal()); }; return ( {t('custodyRefreshTokenModalTitle')} {custodian.iconUrl ? ( {custodian.displayName} ) : ( {custodian.displayName} )} {t('custodyRefreshTokenModalDescription', [custodian.displayName])} {t('custodyRefreshTokenModalSubtitle')} {t('custodyRefreshTokenModalDescription1')} {t('custodyRefreshTokenModalDescription2')} ); }; export default InteractiveReplacementTokenModal;