import { Modal } from 'antd';
import { CheckCircleOutlined, CloseCircleOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
import { Spin } from 'antd';
let updateModal;

export const savingAlert = (data) => {
    updateModal = Modal.confirm({
        title: data.title,
        icon: <Spin />,
        content: data.description,
        centered:true,
        okButtonProps: {
            style: { display: 'none' },
            disabled: true,
        },
        onCancel() {
            if (data.abortProcess){
                data.abortProcess();
            }
        },
    });
};

export const savedAlert = (data) => {
    Modal.success({
        title: data.title,
        icon: <CheckCircleOutlined />,
        content: data.description,
        centered:true,
        cancelButtonProps: {
            style: { display: 'none' },
            disabled: true,
        },
        onOk() {
            console.log('Ok');
        },
    });
};

export const errorAlert = (data) => {
    Modal.error({
        title: data.title,
        icon: <CloseCircleOutlined />,
        content: data.description,
        centered:true,
        cancelButtonProps: {
            style: { display: 'none' },
            disabled: true,
        },
        onOk() {
            if (data.abortProcess){
                data.abortProcess();
            }
        },
    });
};

export const infoAlert = (data) => {
    Modal.info({
        title: data.title,
        icon: <ExclamationCircleOutlined />,
        content: data.description,
        centered:true,
        okButtonProps: {
            style: { display: 'none' },
            disabled: true,
        },
        onCancel() {
            console.log('Cancel');
        },
    });
};

export const updateAlert = (data) => {
    updateModal.update({
        title: data.title,
        content: data.description,
    })
}

export const destroyAlerts = (data) => {
    Modal.destroyAll()
}