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

//# sourceMappingURL=cancelButton.js.map