import React from 'react';
import { storiesOf, forceReRender } from '@storybook/react';
import { text, number, boolean } from '@storybook/addon-knobs';
import { reduxForm, Field } from 'redux-form';

// import configureStore from '../../../storybook/configureStore';
// import { updateRadioRF } from '../../../storybook/reducers/other';
import RadioRF from './component';

// const { getState, dispatch } = configureStore();

const TestWrap = ({ children }) => (<form>{children}</form>);

const RFWrap = reduxForm({
  form: 'rf-wrap2',
})(TestWrap);

const props = ({
  isDisabled = undefined,
  valuePassed = undefined,
  label = undefined,
  // input = undefined,
} = {}) => ({
  isDisabled: boolean('isDisabled', isDisabled),
  valuePassed: text('valuePassed', valuePassed),
  label: text('label', label),
  // input
});

// const onChange = ({ target: { value }}) => { dispatch(updateRadioRF(value)); forceReRender() };

storiesOf('Web|form/Radio')
  .add('ReduxForm', () => (
    <RFWrap>
      <RadioRF {...props({ valuePassed: 'male', label: 'male' })} input={{ checked: false, name: 'sex'}} />
      {/* <RadioRF
        // {...props({ value: getState().other.formRadioRF.value, isRFFWrap: true })}
        // onChange={onChange}
      /> */}
    </RFWrap>
  ), { info: 'redux-form lib, reduxForm() parent, Field parent' });
