import {
	inject,
	observer
} from 'mobx-react';
import {
	toJS
} from 'mobx';
import {
	WeaRadioGroup
} from 'ecCom';
import jquery from 'jquery';

@inject('hrmVacationBalanceReportCopy')
@observer
export default class RadioGroup extends React.Component {
	constructor(props) {
		super(props);
	}

	componentDidMount() {
		const {
			hrmVacationBalanceReportCopy: store
		} = this.props;

		const {
			getRadioGroupConfig,
			chainCall,
		} = store;

		getRadioGroupConfig(chainCall);

	}

	componentDidUpdate(prevProps, prevState) {
		const {
			hrmVacationBalanceReportCopy: store
		} = this.props;
		const {
			setRgHeight
		} = store;

		setRgHeight(jquery('.wea-radio-group').height());
	}

	render() {
		const {
			radioGroup,
			setRef,
			exportActiveParams,
		} = this.props.hrmVacationBalanceReportCopy, {
			config
		} = radioGroup;

		return (
			config.length > 0 && <WeaRadioGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaRadioGroup@el0b21`} config={toJS(config)} ref={ref => setRef(ref,'rg')} onChange={params => exportActiveParams(params)}/>
		)
	}
}