import { connect } from 'react-redux'; import { edit, save } from 'Duck/customField'; import { Form, Button, Message } from 'UI'; import styles from './customFieldForm.css'; @connect(state => ({ field: state.getIn(['customFields', 'instance']), saving: state.getIn(['customFields', 'saveRequest', 'loading']), errors: state.getIn([ 'customFields', 'saveRequest', 'errors' ]), }), { edit, save, }) class CustomFieldForm extends React.PureComponent { setFocus = () => this.focusElement.focus(); onChangeSelect = (event, { name, value }) => this.props.edit({ [ name ]: value }); write = ({ target: { value, name } }) => this.props.edit({ [ name ]: value }); render() { const { field, errors} = this.props; const exists = field.exists(); return (
{ this.focusElement = ref; } } name="key" value={ field.key } onChange={ this.write } placeholder="Field Name" /> { errors &&
{ errors.map(error => { error }) }
}
); } } export default CustomFieldForm;