import {
	toJS
} from 'mobx';
import {
	inject,
	observer
} from 'mobx-react';
import {
	WeaTransfer,
	WeaDialogFooter,
} from 'ecCom';
import CenterSpin from '../../public/components/CenterSpin.js';

@inject('hrmAddressBook')
@observer
export default class Colset extends React.Component {
	componentDidMount() {
		const {hrmAddressBook} = this.props;

		hrmAddressBook.hrmAddressBookPlus.initColset();
	}
	render() {
		const {
			hrmAddressBook
		} = this.props, {
			hrmAddressBookPlus: plusStore
		} = hrmAddressBook, {
			colsetDialog,
			transfer,
			TRANSFER,
			colsetDialogButtons
		} = plusStore, {
			loading,
		} = colsetDialog, {
			data,
			selectedKeys
		} = transfer;

		if (loading) {
			return <CenterSpin ecId={`${this && this.props && this.props.ecId || ''}_CenterSpin@yiso5t`} />
		} else {
			return (
				data && <React.Fragment ecId={`${this && this.props && this.props.ecId || ''}_undefined@jz32bj`}>
					<WeaTransfer ecId={`${this && this.props && this.props.ecId || ''}_WeaTransfer@zd99nn`} {...TRANSFER} data={toJS(data)} selectedKeys={toJS(selectedKeys)}/>
					<WeaDialogFooter ecId={`${this && this.props && this.props.ecId || ''}_WeaDialogFooter@qlpm2j`} buttons={colsetDialogButtons}/>
				</React.Fragment>
			);
		}
	}
}