import React, { PropTypes } from 'react'; import { Textfield, IconButton } from 'react-mdl'; import { HeaderTitle, FormButtons } from '../common'; const trim = (value) => { if (value && value.trim) { return value.trim(); } else { return value; } }; function gerArrayWithEntries (num) { return Array.from(Array(num)); } export const PARAM_PREFIX = 'param_'; const genParams = (input, num = 0, setValue) => (
{gerArrayWithEntries(num).map((v, i) => { const key = `${PARAM_PREFIX}${i + 1}`; return ( setValue(key, target.value)} value={input[key]} /> ); })}
); const AddStrategy = ({ input, setValue, incValue, // clear, onCancel, onSubmit, }) => (
setValue('name', trim(target.value))} value={input.name} />
setValue('description', target.value)} value={input.description} />
{genParams(input, input._params, setValue)} { e.preventDefault(); incValue('_params'); }}/> Add parameter


); AddStrategy.propTypes = { input: PropTypes.object, setValue: PropTypes.func, incValue: PropTypes.func, clear: PropTypes.func, onCancel: PropTypes.func, onSubmit: PropTypes.func, }; export default AddStrategy;