"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"));
const ButtonDelete = (props) => {
    const { ConfirmAction, ConfirmationMsg, ConfirmationTitle, onClickAction, onConfirmWarning, ...restProps } = props;
    const dispatch = (0, react_redux_1.useDispatch)();
    const dispatchConfirmation = (confirmation) => {
        dispatch(PopupRedux.PopupShowConfirmation(confirmation));
        onConfirmWarning?.(confirmation);
    };
    const onClick = () => {
        if (ConfirmAction) {
            let confirmation = {
                CancelButtonText: 'Cancel',
                Header: ConfirmationTitle,
                Msg: ConfirmationMsg,
                ConfirmButtonText: 'Delete',
                CancelAction: null,
                ConfirmAction,
                ShowInputBox: false,
                MessageType: 'Warning',
            };
            dispatchConfirmation(confirmation);
        }
        else {
            onClickAction?.();
        }
    };
    return (React.createElement(SimpleButton_1.default, { "data-name": "delete", tooltip: props.tooltip ?? 'Delete', variant: "text", icon: "delete", iconSize: props.iconSize ?? 24, ...restProps, onClick: () => onClick() }));
};
exports.ButtonDelete = ButtonDelete;
