import React, { Component, PropTypes } from 'react'; import ConfigOptionForm from 'components/forms/ConfigOptionsForm/ConfigOptionForm'; import configOptionInterface from 'interfaces/config_option'; import dropdownOptionInterface from 'interfaces/dropdownOption'; const baseClass = 'config-options-form'; class ConfigOptionsForm extends Component { static propTypes = { completedOptions: PropTypes.arrayOf(configOptionInterface), configNameOptions: PropTypes.arrayOf(dropdownOptionInterface), errors: PropTypes.object, // eslint-disable-line react/forbid-prop-types onRemoveOption: PropTypes.func.isRequired, onFormUpdate: PropTypes.func.isRequired, }; static defaultProps = { errors: {}, }; handleFormUpdate = (option) => { return (fieldName, value) => { const { onFormUpdate } = this.props; const newOption = { ...option, [fieldName]: value }; return onFormUpdate(option, newOption); }; } renderConfigOptionForm = (option, idx) => { const { configNameOptions, errors, onRemoveOption } = this.props; const { handleFormUpdate } = this; const configErrors = errors[option.id] || {}; return (
  • ); } render () { const { completedOptions } = this.props; const { renderConfigOptionForm } = this; return (
    ); } } export default ConfigOptionsForm;