import {
    WeaPopoverHrm,
    WeaLocaleProvider
} from 'ecCom';
import {
    WeaLogView
} from 'comsMobx';
import {
    isEnableMultiLang
} from '../apis/common';
const WeaLogViewComp = WeaLogView.Component;
const {
    LogStore
} = WeaLogView;

class Home extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            key: new Date().getTime(),
            visible: false,
            logStore: new LogStore(),
            logType: '4',
            logSmallType: ''
        }
        window.setLogViewProps = this.setLogViewProps;
    }

    componentDidMount(){
        isEnableMultiLang().then(data => {
            window.inputType = {
                inputType: 'NORMAL'
            }
            if (data.status === '1') {
                if (data.isEnableMultiLang) {
                    window.inputType = {
                        inputType: 'MULTILANG',
                        isBase64: true
                    }
                }
            }
        }, error => {
            window.inputType = {
                inputType: 'NORMAL'
            }
        });
    }

    setLogViewProps = (props) => {
        this.setState({
            key: new Date().getTime(),
            targetId: '',
            visible: true,
            logType: '4',
			logStore: new LogStore(),
            ...props
        });
    }
    onCancel = () => {
        this.setState({
            visible: false
        })
    }
    render() {
        const isSingle = window.location.pathname.indexOf('/spa/hrm/engine') > -1;
        return (
            <div style={{height:"100%"}}>
                <WeaPopoverHrm ecId={`${this && this.props && this.props.ecId || ''}_WeaPopoverHrm@jp3tsb`} />
                <WeaLogViewComp ecId={`${this && this.props && this.props.ecId || ''}_WeaLogViewComp@mc1954`} {...this.state} onCancel={this.onCancel}/>
                <WeaLocaleProvider ecId={`${this && this.props && this.props.ecId || ''}_WeaLocaleProvider@3on3aj`}>
                {this.props.children}
                </WeaLocaleProvider>
            </div>
        )
    }
}

export default Home