import * as React from 'react';
import { useDispatch } from 'react-redux';
import * as PopupRedux from '../../../Redux/ActionsReducers/PopupRedux';
import SimpleButton from '../../../components/SimpleButton';
export const ButtonDelete = (props) => {
    const { ConfirmAction, ConfirmationMsg, ConfirmationTitle, onClickAction, onConfirmWarning, ...restProps } = props;
    const dispatch = 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, { "data-name": "delete", tooltip: props.tooltip ?? 'Delete', variant: "text", icon: "delete", iconSize: props.iconSize ?? 24, ...restProps, onClick: () => onClick() }));
};
