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

//# sourceMappingURL=orderCancelButton.js.map