"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ButtonDelete = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const react_redux_1 = require("react-redux");
const PopupRedux = tslib_1.__importStar(require("../../../Redux/ActionsReducers/PopupRedux"));
const SimpleButton_1 = tslib_1.__importDefault(require("../../../components/SimpleButton"));
class ButtonDeleteComponent extends React.Component {
    render() {
        var _a, _b;
        const _c = this.props, { onConfirmWarning, ConfirmAction, ConfirmationMsg, ConfirmationTitle, onClickAction } = _c, props = tslib_1.__rest(_c, ["onConfirmWarning", "ConfirmAction", "ConfirmationMsg", "ConfirmationTitle", "onClickAction"]);
        return (React.createElement(SimpleButton_1.default, Object.assign({ "data-name": "delete", tooltip: (_a = props.tooltip) !== null && _a !== void 0 ? _a : 'Delete', variant: "text", icon: "delete", iconSize: (_b = props.iconSize) !== null && _b !== void 0 ? _b : 24 }, props, { onClick: () => this.onClick() })));
    }
    onClick() {
        if (this.props.ConfirmAction) {
            let confirmation = {
                CancelButtonText: 'Cancel',
                Header: this.props.ConfirmationTitle,
                Msg: this.props.ConfirmationMsg,
                ConfirmButtonText: 'Delete',
                CancelAction: null,
                ConfirmAction: this.props.ConfirmAction,
                ShowInputBox: false,
                MessageType: 'Warning',
            };
            this.props.onConfirmWarning(confirmation);
        }
        else {
            this.props.onClickAction();
        }
    }
}
function mapStateToProps(state, ownProps) {
    return {
        ConfirmAction: ownProps.ConfirmAction,
        ConfirmationMsg: ownProps.ConfirmationMsg,
        ConfirmationTitle: ownProps.ConfirmationTitle,
    };
}
function mapDispatchToProps(dispatch) {
    return {
        onConfirmWarning: (confirmation) => dispatch(PopupRedux.PopupShowConfirmation(confirmation)),
    };
}
exports.ButtonDelete = (0, react_redux_1.connect)(mapStateToProps, mapDispatchToProps)(ButtonDeleteComponent);
