import Button from '../../button';
import Dialog from '..';
import Message from '../../message';
import React from 'react';
import ReactDOM from 'react-dom';
class Demo extends React.Component {
    constructor() {
        super(...arguments);
        this.state = {
            visible: false,
            loading: false,
        };
        this.onOpen = () => {
            this.setState({
                visible: true,
            });
        };
        this.onOk = () => {
            return new Promise(resolve => {
                this.setState({
                    loading: true,
                });
                setTimeout(resolve, 2000);
            }).then(() => {
                Message.success('Deleted successfully!');
                this.setState({
                    loading: false,
                    visible: false,
                });
            });
        };
        this.onClose = () => {
            this.setState({
                visible: false,
            });
        };
    }
    render() {
        const okProps = {
            loading: this.state.loading,
        };
        return (React.createElement("div", null,
            React.createElement(Button, { onClick: this.onOpen, type: "primary" }, "Dialog Promise"),
            React.createElement(Dialog, { title: "Welcome to Alibaba.com", visible: this.state.visible, okProps: okProps, onOk: this.onOk, onCancel: this.onClose, onClose: this.onClose }, "Start your business here by searching a popular product")));
    }
}
const popupConfirm = () => {
    Dialog.confirm({
        title: 'Confirm',
        content: 'Do you confirm deleting this content?',
        onOk: () => {
            return new Promise(resolve => {
                setTimeout(resolve, 2000);
            }).then(() => {
                Message.success('Deleted successfully!');
            });
        },
    });
};
ReactDOM.render(React.createElement("div", null,
    React.createElement(Demo, null),
    React.createElement("br", null),
    React.createElement(Button, { type: "primary", warning: true, onClick: popupConfirm }, "Quick Confirm Promise")), document.getElementById('dialog-demo-7'));
