"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "HistoryView", {
    enumerable: true,
    get: function() {
        return HistoryView;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _orderHistory = require("../../../../../../block/orderHistory");
const _tradingPageContext = require("../../../../../../page/trading/context/tradingPageContext");
const _tabContext = require("../../../../../../tab/tabContext");
const _hooks = require("@orderly.network/hooks");
const _types = require("@orderly.network/types");
const _react = require("react");
const HistoryView = ()=>{
    const [side, setSide] = (0, _react.useState)("");
    const [status, setStauts] = (0, _react.useState)("");
    const { state } = (0, _hooks.useAccount)();
    const { symbol, onSymbolChange } = (0, _react.useContext)(_tradingPageContext.TradingPageContext);
    const { data: tabExtraData } = (0, _tabContext.useTabContext)();
    const [data, { isLoading, loadMore, cancelOrder, refresh }] = (0, _hooks.useOrderStream)({
        // @ts-ignore
        side,
        // @ts-ignore
        status,
        symbol: tabExtraData.showAllSymbol ? "" : symbol
    });
    const onCancelOrder = (0, _react.useCallback)((orderId, symbol)=>{
        // @ts-ignore
        return cancelOrder(orderId, symbol).then(()=>{
            // update history list
            return refresh();
        });
    }, [
        refresh
    ]);
    return /*#__PURE__*/ (0, _jsxruntime.jsx)(_orderHistory.HistoryListViewFull, {
        isLoading: isLoading,
        // @ts-ignore
        dataSource: state.status < _types.AccountStatusEnum.EnableTrading ? [] : data,
        onSideChange: setSide,
        onStatusChange: setStauts,
        onSymbolChange: onSymbolChange,
        onCancelOrder: onCancelOrder,
        side: side,
        status: status,
        loadMore: loadMore
    });
};

//# sourceMappingURL=index.js.map