All files / src/components/Form/RadioList index.jsx

20% Statements 2/10
100% Branches 0/0
0% Functions 0/7
20% Lines 2/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40                3x                                       3x                      
import 'react-select/dist/react-select.css';
 
import React from 'react';
import { HOC as formsyDecorator } from 'formsy-react';
import Field from '../Field';
import Radio from './Radio';
import PropTypes from 'prop-types';
 
const RadioList = (props) => {
  const { name, label, items } = props;
  return <Field label={label}
      getErrorMessage={() => props.getErrorMessage()}
      showError={() => props.showError()}
      showRequired={() => props.showRequired()}>
    {
      items.map((item) =>
        <Radio item={item}
            name={name}
            key={item}
            onChecked={(e, option) => handleChange(e, option)} />)
    }
  </Field>;
 
  function handleChange(e, item) {
    props.setValue(item);
  }
};
 
RadioList.propTypes = {
  getErrorMessage: PropTypes.func.isRequired,
  showError: PropTypes.func.isRequired,
  showRequired: PropTypes.func.isRequired,
  setValue: PropTypes.func.isRequired,
  name: PropTypes.string,
  label: PropTypes.string,
  items: PropTypes.array.isRequired,
};
 
export default formsyDecorator(RadioList);