import '../../style/groupSetting.less';
import React, {Component} from 'react';
import {inject,observer} from 'mobx-react';
import {WeaTop, WeaAlertPage, WeaDialogFooter} from 'ecCom';
import {i18n} from '../../public/i18n';
import Info from './Info';

@inject('hrmGroupSetting')
@observer
export default class GroupInfo4Coms extends Component{
    constructor(props) {
        super(props);
	}

	componentDidMount() {
		this.init();
	}

	componentWillReceiveProps(nextProps) {
        this.init();
    }

    init = () => {
        const {
            hrmGroupSetting: store,
            groupId,
            callback
        } = this.props;
        store.checkAuthorized('kq/group', null, () => store.initSingle(groupId, callback));
    }
    
    render(){
        const {
            hrmGroupSetting: store
        } = this.props;
		const {
            containerInitFinished,
            dialogFootButtons,
        } = store;
        let title = i18n.label['389064']();
		const {buttons, menus} = dialogFootButtons;

        let children = [
            (
                <div style={{height: '100%'}}>
                    <div style={{height: 'calc(100% - 64px)', position: 'relative'}}>
                        <Info ecId={`${this && this.props && this.props.ecId || ''}_Info@p8cxnm`} store={store} />
                    </div>
                    <WeaDialogFooter ecId={`${this && this.props && this.props.ecId || ''}_WeaDialogFooter@eacpnh`} buttons={buttons} moreBtn={{datas: menus}}/>
                </div>
            )
        ]
        
        return (
            <div className="hrm_module_container">
			{
				containerInitFinished.init && containerInitFinished.authorized && children
			}
			{
				containerInitFinished.init && !containerInitFinished.authorized && 
              	<WeaAlertPage ecId={`${this && this.props && this.props.ecId || ''}_WeaAlertPage@y9p9d6`}>
                  	<div style={{ color: '#000' }}>{i18n.message.authFailed()}</div>
              	</WeaAlertPage>
			}
			</div>
        )
    }
}