import { jsx as _jsx } from "react/jsx-runtime";
import Button from "../../../button";
import { toast } from "../../../toast";
import { useState, useContext } from "react";
import { OrderListContext } from "../shared/orderListContext";
export const CancelButton = (props)=>{
    const { order } = props;
    const { onCancelOrder } = useContext(OrderListContext);
    const [isLoading, setIsLoading] = useState(false);
    return /*#__PURE__*/ _jsx(Button, {
        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.error(error.message);
            }).finally(()=>{
                setIsLoading(false);
            });
        },
        children: "Cancel"
    });
};

//# sourceMappingURL=cancelButton.js.map