import React, { useRef } from 'react'; import { connect } from 'react-redux'; import { edit, save } from 'Duck/customField'; import { Form, Input, Button } from 'UI'; import styles from './customFieldForm.module.css'; const CustomFieldForm = ({ field, saving, errors, edit, save, onSave, onClose, onDelete }) => { const focusElementRef = useRef(null); const setFocus = () => focusElementRef.current.focus(); const onChangeSelect = (event, { name, value }) => edit({ [name]: value }); const write = ({ target: { value, name } }) => edit({ [name]: value }); const exists = field.exists(); return (

{exists ? 'Update' : 'Add'} Metadata Field

); }; const mapStateToProps = (state) => ({ field: state.getIn(['customFields', 'instance']), saving: state.getIn(['customFields', 'saveRequest', 'loading']), errors: state.getIn(['customFields', 'saveRequest', 'errors']), }); export default connect(mapStateToProps, { edit, save })(CustomFieldForm);