"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "Toolbar", {
    enumerable: true,
    get: function() {
        return Toolbar;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _button = /*#__PURE__*/ _interop_require_default(require("../../button"));
const _label = require("../../label");
const _checkbox = require("../../checkbox");
const _hooks = require("@orderly.network/hooks");
const _modal = require("../../modal");
function _interop_require_default(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
const Toolbar = (props)=>{
    const [cancelAll, { error: cancelOrderError, isMutating: cancelMutating }] = (0, _hooks.useMutation)("/v1/orders", "DELETE");
    function cancelAllOrder() {
        _modal.modal.confirm({
            title: "Cancel all orders",
            content: /*#__PURE__*/ (0, _jsxruntime.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__*/ (0, _jsxruntime.jsxs)("div", {
        className: "orderly-data-list-filter orderly-flex orderly-justify-between orderly-items-center orderly-py-3 orderly-px-4",
        children: [
            /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                className: "orderly-flex orderly-items-center orderly-gap-1",
                children: [
                    /*#__PURE__*/ (0, _jsxruntime.jsx)(_checkbox.Checkbox, {
                        id: "showAll",
                        checked: props.showAllSymbol,
                        onCheckedChange: props.onShowAllSymbolChange
                    }),
                    /*#__PURE__*/ (0, _jsxruntime.jsx)(_label.Label, {
                        htmlFor: "showAll",
                        className: "orderly-text-base-contrast-54",
                        children: "Show all instruments"
                    })
                ]
            }),
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_button.default, {
                variant: "outlined",
                size: "small",
                color: "tertiary",
                onClick: cancelAllOrder,
                children: "Cancel all"
            })
        ]
    });
};

//# sourceMappingURL=toolbar.js.map