import {
    inject,
    observer
} from 'mobx-react'
import {
    WeaDialog,
    WeaRightMenu
} from 'ecCom'

import Expression from './Expression';
import ShareForm from './ShareForm';
import LoginTestForm from './LoginTestForm';
import AlgorithmFormSetting from './AlgorithmFormSetting';
import AlgorithmTestForm from './AlgorithmTestForm';

@inject('intelogin')
@observer
export default class SubDialog extends React.Component {
    constructor(props) {
        super(props);
    }

    getChildren = () => {
        const {
            intelogin
        } = this.props, {
            subDialog,
            mainTab,
        } = intelogin, {
            type
        } = subDialog, {
            key
        } = mainTab;

        if (type == 'share') {
            return <ShareForm ecId={`${this && this.props && this.props.ecId || ''}_ShareForm@v7euzi`} />
        }
        if (type == 'expression') {
            return <Expression ecId={`${this && this.props && this.props.ecId || ''}_Expression@k8me4j`} />
        }
        if (type == 'encrypt_new') {
            return <AlgorithmFormSetting ecId={`${this && this.props && this.props.ecId || ''}_AlgorithmFormSetting@a8um1h`} />
        }
        if (type == '2') {
            return (key == '0') ? <LoginTestForm ecId={`${this && this.props && this.props.ecId || ''}_LoginTestForm@8ognfv`} /> : <AlgorithmTestForm ecId={`${this && this.props && this.props.ecId || ''}_AlgorithmTestForm@rqn4og`} />
        }

    }

    render() {
        const {
            intelogin
        } = this.props, {
            subDialog,
            closeDialog,
            sStyle,
            sMenus,
        } = intelogin, {
            title,
            visible,
        } = subDialog, {
            buttons,
            dropMenuDatas
        } = sMenus;

        return (
            <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@4kh4hg`}
                title={title}
                icon='icon-coms-integration'
                iconBgcolor="#1a57a0"
                visible={visible}
                hasScroll={true}
                onCancel={() => closeDialog()}
                buttons={buttons}
                style={sStyle}
                moreBtn={{datas:dropMenuDatas}}
            >
                <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@f5aum8`} datas={dropMenuDatas}>
                    {visible && this.getChildren()}
                </WeaRightMenu>
            </WeaDialog>
        )

    }
}