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

import StaticFormInfo from './StaticFormInfo';

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

	getButtons = () => {
		const {
			hrmWorkHour,
		} = this.props, {
			closeDialog,
			synchro,
		} = hrmWorkHour;

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

		return buttons;
	}

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

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

	}
}