import { jsx as _jsx } from "react/jsx-runtime";
import React, { useContext, useMemo } from "react";
import { Table } from "../../table";
import { Numeral, Text } from "../../text";
import { OrderSide } from "@orderly.network/types";
import { SymbolContext } from "../../provider";
import { cn } from "../../utils/css";
export const TradeHistory = (props)=>{
    const { quote, quote_dp, base, base_dp } = useContext(SymbolContext);
    const columns = useMemo(()=>{
        return [
            {
                title: "Time",
                dataIndex: "ts",
                render (value, record, index) {
                    return /*#__PURE__*/ _jsx(Text, {
                        rule: "date",
                        formatString: "HH:mm:ss",
                        className: "orderly-text-base-contrast-80 orderly-text-3xs",
                        children: value
                    });
                }
            },
            {
                title: `Price(${quote})`,
                dataIndex: "price",
                render (value, record, index) {
                    return /*#__PURE__*/ _jsx(Numeral, {
                        precision: quote_dp,
                        className: record.side === OrderSide.BUY ? "orderly-text-trade-profit orderly-text-3xs" : "orderly-text-trade-loss orderly-text-3xs",
                        children: value
                    });
                }
            },
            {
                title: `Qty(${base})`,
                dataIndex: "size",
                align: "right",
                render (value, record, index) {
                    return /*#__PURE__*/ _jsx(Numeral, {
                        precision: base_dp,
                        className: record.side === OrderSide.BUY ? "orderly-text-trade-profit orderly-text-3xs" : "orderly-text-trade-loss orderly-text-3xs",
                        children: value
                    });
                }
            }
        ];
    }, [
        base,
        quote
    ]);
    return /*#__PURE__*/ _jsx(Table, {
        dataSource: props.dataSource,
        columns: columns,
        loading: props.loading,
        className: "orderly-text-3xs desktop:orderly-text-2xs",
        headerClassName: cn("orderly-text-base-contrast-36 orderly-bg-base-900 orderly-p-0", props.headerClassName),
        generatedRowKey: (record, index)=>// @ts-ignore
            `record.ts_${record.price}_${record.size}_${index}`
    });
};

//# sourceMappingURL=tradeHistory.js.map