import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import Button from "../../button";
import { Label } from "../../label";
import { Checkbox } from "../../checkbox";
import { useMutation } from "@orderly.network/hooks";
import { modal } from "../../modal";
export const Toolbar = (props)=>{
    const [cancelAll, { error: cancelOrderError, isMutating: cancelMutating }] = useMutation("/v1/orders", "DELETE");
    function cancelAllOrder() {
        modal.confirm({
            title: "Cancel all orders",
            content: /*#__PURE__*/ _jsx("div", {
                className: "orderly-text-base-contrast-54 orderly-text-2xs desktop:orderly-text-sm",
                children: "Are you sure you want to cancel all of your pending orders?"
            }),
            contentClassName: "desktop:orderly-w-[364px]",
            onOk: async ()=>{
                // do cancel all orders
                try {
                    await cancelAll(null, {
                        "source_type": "ALL"
                    });
                } catch (error) {
                    // @ts-ignore
                    if (error?.message !== undefined) {
                        // @ts-ignore
                        toast.error(error.message);
                    }
                } finally{
                    Promise.resolve();
                }
            },
            onCancel: ()=>{
                return Promise.reject();
            }
        }).catch((error)=>{});
    }
    return /*#__PURE__*/ _jsxs("div", {
        className: "orderly-data-list-filter orderly-flex orderly-justify-between orderly-items-center orderly-py-3 orderly-px-4",
        children: [
            /*#__PURE__*/ _jsxs("div", {
                className: "orderly-flex orderly-items-center orderly-gap-1",
                children: [
                    /*#__PURE__*/ _jsx(Checkbox, {
                        id: "showAll",
                        checked: props.showAllSymbol,
                        onCheckedChange: props.onShowAllSymbolChange
                    }),
                    /*#__PURE__*/ _jsx(Label, {
                        htmlFor: "showAll",
                        className: "orderly-text-base-contrast-54",
                        children: "Show all instruments"
                    })
                ]
            }),
            /*#__PURE__*/ _jsx(Button, {
                variant: "outlined",
                size: "small",
                color: "tertiary",
                onClick: cancelAllOrder,
                children: "Cancel all"
            })
        ]
    });
};

//# sourceMappingURL=toolbar.js.map