import {
	inject,
	observer,
} from 'mobx-react'
import {
	WeaDialog,
	WeaMoreButton,
} from 'ecCom'
import {
	Button,
} from 'antd'
import {
	i18n
} from '../../public/i18n';

import SubFormInfo from './SubFormInfo';

@inject('hrmAttendanceSetting')
@observer
export default class MainDialog extends React.Component {
	constructor(props) {
		super(props);
		this.state = {
			width: 700,
			height: 245,
		}
	}

	getButtons = () => {
		const {
			hrmAttendanceSetting,
		} = this.props, {
			save,
		} = hrmAttendanceSetting;

		let buttons = [
			(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@gpfagm`} type="primary" onClick={() => save('sub')}>{i18n.button.save()}</Button>),
			(<WeaMoreButton ecId={`${this && this.props && this.props.ecId || ''}_WeaMoreButton@k8qt8b`} />)
		];

		return buttons;
	}

	render() {
		const {
			hrmAttendanceSetting,
		} = this.props, {
			mainDialog,
			closeDialog,
		} = hrmAttendanceSetting, {
			visible,
			title,
		} = mainDialog, {
			width,
			height,
		} = this.state;

		return (
			<WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@esw7gk`}
                title={title}
                icon="icon-coms-hrm"
                iconBgcolor="#217346"
                visible={visible}
                closable={true}
                hasScroll={true}
                onCancel={() => closeDialog()}
                buttons={this.getButtons()}
                style={{width: width, height: height}}
                onChangeHeight={(h) => this.setState({height: h})}
            >
				{visible && <SubFormInfo ecId={`${this && this.props && this.props.ecId || ''}_SubFormInfo@qn2kdf`} /> }
            </WeaDialog>
		)

	}
}