import PropTypes from 'prop-types'; import React from 'react'; import { reduxForm } from 'redux-form'; import { withTranslation } from 'react-i18next'; import i18n from 'i18next'; import NewFolderForm from './NewFolderForm'; import ExitIcon from '../../../images/exit.svg'; class NewFolderModal extends React.Component { componentDidMount() { this.newFolderModal.focus(); } render() { return (
{ this.newFolderModal = element; }} >

{this.props.t('NewFolderModal.Title')}

); } } NewFolderModal.propTypes = { closeModal: PropTypes.func.isRequired, t: PropTypes.func.isRequired }; function validate(formProps) { const errors = {}; if (!formProps.name) { errors.name = i18n.t('NewFolderModal.EnterName'); } else if (formProps.name.trim().length === 0) { errors.name = i18n.t('NewFolderModal.EmptyName'); } else if (formProps.name.match(/\.+/i)) { errors.name = i18n.t('NewFolderModal.InvalidExtension'); } return errors; } export default withTranslation()(reduxForm({ form: 'new-folder', fields: ['name'], validate })(NewFolderModal));