import { jsx as _jsx } from "react/jsx-runtime";
import { OrdersView } from "../../../../../../block/orders";
import { useContext, useState } from "react";
import { useOrderStream, useAccount, useSessionStorage } from "@orderly.network/hooks";
import { TradingPageContext } from "../../../../../../page/trading/context/tradingPageContext";
import { AccountStatusEnum } from "@orderly.network/types";
import { TabContext } from "../../../../../../tab";
import { OrderStatus } from "@orderly.network/types";
export const OrdersPane = (props)=>{
    const context = useContext(TradingPageContext);
    const tabContext = useContext(TabContext);
    const [showAllSymbol, setShowAllSymbol] = useSessionStorage("showAllSymbol_orders", true);
    const [symbol, setSymbol] = useState(()=>showAllSymbol ? "" : context.symbol);
    const [data, { isLoading, loadMore, cancelOrder, updateOrder, cancelAlgoOrder, updateAlgoOrder }] = useOrderStream({
        status: OrderStatus.INCOMPLETE,
        symbol: symbol
    });
    const onShowAllSymbolChange = (isAll)=>{
        setSymbol(isAll ? "" : context.symbol);
        setShowAllSymbol(isAll);
    };
    const { state } = useAccount();
    // const onCancelOrder = useCallback(
    //   (orderId: number | OrderEntity, symbol: string): Promise<any> => {
    //     // @ts-ignore
    //     return cancelOrder(orderId, symbol);
    //   },
    //   []
    // );
    return /*#__PURE__*/ _jsx(OrdersView, {
        // @ts-ignore
        dataSource: state.status < AccountStatusEnum.EnableTrading ? [] : data,
        isLoading: isLoading,
        symbol: context.symbol,
        showAllSymbol: showAllSymbol,
        cancelOrder: cancelOrder,
        cancelAlgoOrder: cancelAlgoOrder,
        onShowAllSymbolChange: onShowAllSymbolChange,
        editOrder: updateOrder,
        editAlgoOrder: updateAlgoOrder,
        onSymbolChange: context.onSymbolChange,
        loadMore: loadMore
    });
};

//# sourceMappingURL=index.js.map