"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "MyOrders", {
    enumerable: true,
    get: function() {
        return MyOrders;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _react = require("react");
const _hooks = require("@orderly.network/hooks");
const _tradingPageContext = require("../../../../../../page/trading/context/tradingPageContext");
const _types = require("@orderly.network/types");
const _full = require("../../../../../../block/orders/full");
const _tabContext = require("../../../../../../tab/tabContext");
const _useFormatOrderHistory = require("../../../../../../page/trading/shared/hooks/useFormatOrderHistory");
const MyOrders = (props)=>{
    const context = (0, _react.useContext)(_tradingPageContext.TradingPageContext);
    const { data: tabExtraData } = (0, _tabContext.useTabContext)();
    // const [symbol, setSymbol] = useState(() =>
    //   tabExtraData.showAllSymbol ? "" : context.symbol
    // );
    const [side, setSide] = (0, _react.useState)("");
    const [data, { isLoading, loadMore, cancelOrder, updateOrder, cancelAlgoOrder, updateAlgoOrder }] = (0, _hooks.useOrderStream)({
        status: props.status,
        symbol: tabExtraData.showAllSymbol ? "" : context.symbol,
        // @ts-ignore
        side,
        excludes: props.status === _types.OrderStatus.FILLED ? [] : [
            _types.AlgoOrderRootType.POSITIONAL_TP_SL,
            _types.AlgoOrderRootType.TP_SL
        ]
    });
    // const onShowAllSymbolChange = (isAll: boolean) => {
    //   setSymbol(isAll ? "" : context.symbol);
    //   setShowAllSymbol(isAll);
    // };
    const { state } = (0, _hooks.useAccount)();
    const onCancelOrder = (0, _react.useCallback)((orderId, symbol)=>{
        return cancelOrder(orderId, symbol);
    }, []);
    const formattedData = (0, _useFormatOrderHistory.useFormatOrderHistory)(state.status < _types.AccountStatusEnum.EnableTrading || !data ? [] : data);
    return /*#__PURE__*/ (0, _jsxruntime.jsx)(_full.OrdersViewFull, {
        // @ts-ignore
        dataSource: formattedData,
        isLoading: isLoading,
        symbol: context.symbol,
        onSideChange: setSide,
        // @ts-ignore
        side: side,
        showAllSymbol: tabExtraData.showAllSymbol,
        cancelOrder: onCancelOrder,
        editOrder: updateOrder,
        cancelAlgoOrder: cancelAlgoOrder,
        editAlgoOrder: updateAlgoOrder,
        onSymbolChange: context.onSymbolChange,
        loadMore: loadMore,
        status: props.status
    });
};

//# sourceMappingURL=index.js.map