import PropTypes from 'prop-types'; import React, { useState } from 'react'; import { useSelector } from 'react-redux'; import { FormTextField, TEXT_FIELD_SIZES, TEXT_FIELD_TYPES, } from '../../../components/component-library'; import { useI18nContext } from '../../../hooks/useI18nContext'; import BottomButtons from './bottom-buttons'; PrivateKeyImportView.propTypes = { importAccountFunc: PropTypes.func.isRequired, }; export default function PrivateKeyImportView({ importAccountFunc }) { const t = useI18nContext(); const [privateKey, setPrivateKey] = useState(''); const warning = useSelector((state) => state.appState.warning); function handleKeyPress(event) { if (privateKey !== '' && event.key === 'Enter') { event.preventDefault(); _importAccountFunc(); } } function _importAccountFunc() { importAccountFunc('Private Key', [privateKey]); } return ( <> setPrivateKey(event.target.value)} inputProps={{ onKeyPress: handleKeyPress, }} marginBottom={4} /> ); }