"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "OrderCancelButton", {
    enumerable: true,
    get: function() {
        return OrderCancelButton;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _react = require("react");
const _button = /*#__PURE__*/ _interop_require_default(require("../../button"));
const _toast = require("../../toast");
function _interop_require_default(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
const OrderCancelButton = (props)=>{
    const { onCancelOrder, order } = props;
    const [isLoading, setIsLoading] = (0, _react.useState)(false);
    return /*#__PURE__*/ (0, _jsxruntime.jsx)(_button.default, {
        className: "orderly-flex-1",
        size: "small",
        variant: "outlined",
        color: "tertiary",
        loading: isLoading,
        onClick: (event)=>{
            if (!onCancelOrder) return;
            event.preventDefault();
            event.stopPropagation();
            setIsLoading(true);
            onCancelOrder(order).then((res)=>res, (error)=>{
                _toast.toast.error(error.message);
            }).finally(()=>{
                setIsLoading(false);
            });
        },
        children: "Cancel"
    });
};

//# sourceMappingURL=orderCancelButton.js.map