import {
    inject,
    observer,
} from 'mobx-react'

import {
    WeaAuth
} from 'ecCom'

import {
    Spin
} from 'antd'

import React from 'react'
const toJS = mobx.toJS;

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

    handleOk(data) {
        const {
            hrmBirthdayRemindSet
        } = this.props, {
            add,
            setVisible,
            setAuthParams
        } = hrmBirthdayRemindSet;

        setAuthParams(data); //设置参数
        add();
        setVisible(false);
    }

    render() {
        const {
            hrmBirthdayRemindSet
        } = this.props, {
            tabOne,
            setVisible,
        } = hrmBirthdayRemindSet, {
            auth
        } = tabOne, {
            loading,
            visible,
            title,
            conditions
        } = auth;

        if (loading) {
            return (
                <div className='hrm-loading-center-small'>
                    <Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@dp51oh`} spinning={loading}></Spin>
                </div>
            )
        } else {
            return (
                <WeaAuth ecId={`${this && this.props && this.props.ecId || ''}_WeaAuth@9ebu8y`}
                    modalClassName='hrm-auth'
                    visible={visible}
                    title={title}
                    height={290}
                    icon="icon-coms-hrm"
                    iconBgcolor="#217346"
                    conditions={toJS(conditions)}
                    onOk={data => this.handleOk(data)}
                    onCancel={() => setVisible(false)}
                />
            )
        }

    }
}