import {
    inject,
    observer
} from 'mobx-react';
import {
    WeaSearchGroup,
    WeaLocaleProvider,
} from 'ecCom';
import {
    Spin,
} from 'antd'
const getLabel = WeaLocaleProvider.getLabel;

import LoginForm from './LoginForm';
import TableEdit from './TableEdit';
@inject('intelogin')
@observer
export default class LoginSetting extends React.Component {
    constructor(props) {
        super(props);
    }

    componentDidMount() {
        const {
            intelogin
        } = this.props, {
            getDefaultEntranceUrl,
            getLoginForm,
            mainDialog
        } = intelogin, {
            type
        } = mainDialog;

        if(type == 'BTN_NEW') {
          let params = {};
          if(this.props.typename) {
            params = {typename: this.props.typename};
          }else if(this.props.type) {
            params = {type: this.props.type};
          }
          getDefaultEntranceUrl(params);
        }else {
          getLoginForm();
        }
    }

    render() {
        const {
            intelogin,
        } = this.props, {
            loginForm,
        } = intelogin, {
            loading,
            typename,
        } = loginForm;

        if (loading) {
            return (
                <div className='integration-loading-center-small'>
                    <Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@oxhajb`} spinning={loading}></Spin>
                </div>
            )
        } else {
            return (
                <div>
                    <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@wnmzrv`}
                        showGroup
                        title={getLabel(1361, '基本信息')}
                        children={<LoginForm ecId={`${this && this.props && this.props.ecId || ''}_LoginForm@frmi9g`} />}
                    />
                    {['6','7','8', '11', '12'].includes(typename) || this.props.type === "mail" ? null : <TableEdit ecId={`${this && this.props && this.props.ecId || ''}_TableEdit@o3enw5`} />}
                </div>
            )
        }
    }

}