import React, { useContext } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import Modal from '../../app/modal'; 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 { Text } from '../../component-library'; import Box from '../../ui/box'; import { BLOCK_SIZES, BackgroundColor, DISPLAY, FLEX_WRAP, FLEX_DIRECTION, BorderRadius, FONT_WEIGHT, TEXT_ALIGN, AlignItems, } from '../../../helpers/constants/design-system'; 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 renderCustodyInfo = () => { let img; if (custodian.iconUrl) { img = ( {custodian.displayName} ); } else { img = ( {custodian.displayName} ); } return ( <> {img} {t('custodyRefreshTokenModalTitle')} {t('custodyRefreshTokenModalDescription', [custodian.displayName])} {t('custodyRefreshTokenModalSubtitle')} {t('custodyRefreshTokenModalDescription1')} {t('custodyRefreshTokenModalDescription2')} ); }; const handleSubmit = () => { global.platform.openTab({ url, }); trackEvent({ category: 'MMI', event: 'User clicked refresh token link', }); }; const handleClose = () => { dispatch(hideModal()); }; return ( {renderCustodyInfo(custodian)} ); }; export default InteractiveReplacementTokenModal;