import { jsx as _jsx } from "react/jsx-runtime";
import { HistoryListViewFull } from "../../../../../../block/orderHistory";
import { TradingPageContext } from "../../../../../../page/trading/context/tradingPageContext";
import { useTabContext } from "../../../../../../tab/tabContext";
import { useOrderStream, useAccount } from "@orderly.network/hooks";
import { AccountStatusEnum } from "@orderly.network/types";
import { useCallback, useContext, useState } from "react";
export const HistoryView = ()=>{
    const [side, setSide] = useState("");
    const [status, setStauts] = useState("");
    const { state } = useAccount();
    const { symbol, onSymbolChange } = useContext(TradingPageContext);
    const { data: tabExtraData } = useTabContext();
    const [data, { isLoading, loadMore, cancelOrder, refresh }] = useOrderStream({
        // @ts-ignore
        side,
        // @ts-ignore
        status,
        symbol: tabExtraData.showAllSymbol ? "" : symbol
    });
    const onCancelOrder = useCallback((orderId, symbol)=>{
        // @ts-ignore
        return cancelOrder(orderId, symbol).then(()=>{
            // update history list
            return refresh();
        });
    }, [
        refresh
    ]);
    return /*#__PURE__*/ _jsx(HistoryListViewFull, {
        isLoading: isLoading,
        // @ts-ignore
        dataSource: state.status < AccountStatusEnum.EnableTrading ? [] : data,
        onSideChange: setSide,
        onStatusChange: setStauts,
        onSymbolChange: onSymbolChange,
        onCancelOrder: onCancelOrder,
        side: side,
        status: status,
        loadMore: loadMore
    });
};

//# sourceMappingURL=index.js.map