import React, { useContext, useState } from 'react'; import PropTypes from 'prop-types'; import { useSelector, useDispatch } from 'react-redux'; import withModalProps from '../../../../helpers/higher-order-components/with-modal-props'; import Box from '../../../ui/box'; import { BannerAlert, ButtonIcon, ButtonLink, ButtonPrimary, ButtonSecondary, ButtonSecondarySize, FormTextField, Icon, IconName, IconSize, Label, Text, } from '../../../component-library'; import { AlignItems, Display, FlexDirection, IconColor, JustifyContent, Severity, Size, TextAlign, TextVariant, } from '../../../../helpers/constants/design-system'; import { useI18nContext } from '../../../../hooks/useI18nContext'; import CheckBox from '../../../ui/check-box'; import { setDisabledRpcMethodPreference } from '../../../../store/actions'; import { getDisabledRpcMethodPreferences } from '../../../../selectors'; import { MetaMetricsEventCategory, MetaMetricsEventName, } from '../../../../../shared/constants/metametrics'; import { MetaMetricsContext } from '../../../../contexts/metametrics'; const EthSignModal = ({ hideModal }) => { const [isEthSignChecked, setIsEthSignChecked] = useState(false); const [showTextField, setShowTextField] = useState(false); const [inputKeyword, setInputKeyword] = useState(''); const disabledRpcMethodPreferences = useSelector( getDisabledRpcMethodPreferences, ); const t = useI18nContext(); const dispatch = useDispatch(); const trackEvent = useContext(MetaMetricsContext); const handleSubmit = () => { dispatch( setDisabledRpcMethodPreference( 'eth_sign', !disabledRpcMethodPreferences.eth_sign, ), ); hideModal(); }; const isValid = inputKeyword === t('toggleEthSignModalFormValidation'); return ( hideModal()} ariaLabel={t('close')} /> {t('toggleEthSignModalTitle')} {t('toggleEthSignModalDescription')} {t('learnMoreUpperCase')} {t('toggleEthSignModalBannerText')} {t('toggleEthSignModalBannerBoldText')} {showTextField ? ( 0 && !isValid} helpText={ inputKeyword.length > 0 && !isValid && t('toggleEthSignModalFormError') } onChange={(event) => setInputKeyword(event.target.value)} value={inputKeyword} onPaste={(event) => event.preventDefault()} /> ) : ( { setIsEthSignChecked(!isEthSignChecked); }} /> )} hideModal()} size={ButtonSecondarySize.Lg} block > {t('cancel')} {showTextField ? ( {t('enableSnap')} ) : ( { setShowTextField(true); trackEvent({ category: MetaMetricsEventCategory.Settings, event: MetaMetricsEventName.OnboardingWalletAdvancedSettings, properties: { location: 'Settings', enable_eth_sign: true, }, }); }} > {t('continue')} )} ); }; EthSignModal.propTypes = { // The function to close the Modal hideModal: PropTypes.func, }; export default withModalProps(EthSignModal);