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

import {LogViewStore} from "../stores/logview"

class Home extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            keys: new Date().getTime(),
            visible: false,
            logViewStore: new LogViewStore()
          
        }
        window.setLogViewProp = this.setLogViewProp;
    }

    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'
            }
        });
    }

    setLogViewProp = (props) => {
        this.setState({
            visible: true,
            logViewStore: new LogViewStore(),
            ...props
        });
    }
    onCancel = () => {
        this.setState({
            visible: false
        })
    }

    render() {
        //const isSingle = window.location.pathname.indexOf('/spa/hrm/engine') > -1;
        return (
            <div style={{height:"100%"}}>
                <WeaPopoverHrm inDialog={true}  ecId={`${this && this.props && this.props.ecId || ''}_WeaPopoverHrm@jp3tsb`} />
                <LogView ecId={`${this && this.props && this.props.ecId || ''}_LogView@mc1954`} {...this.state} onCancel={this.onCancel}/>
                <WeaLocaleProvider ecId={`${this && this.props && this.props.ecId || ''}_WeaLocaleProvider@3on3aj`}>
                {this.props.children}
                </WeaLocaleProvider>

            </div>
        )
    }
}

export default Home