mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
add limit to the order table
This commit is contained in:
parent
b97ec7bb1e
commit
2953518af9
|
@ -1,15 +1,18 @@
|
||||||
import {Checkbox, Group, Table} from "@mantine/core";
|
import {Button, Checkbox, Group, Table} from "@mantine/core";
|
||||||
import React, {useState} from "react";
|
import React, {useState} from "react";
|
||||||
import {Order} from "../types";
|
import {Order} from "../types";
|
||||||
|
|
||||||
interface OrderListTableProps {
|
interface OrderListTableProps {
|
||||||
orders: Order[];
|
orders: Order[];
|
||||||
onClick?: (order: Order) => void;
|
onClick?: (order: Order) => void;
|
||||||
|
limit?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const OrderListTable = (props: OrderListTableProps) => {
|
const OrderListTable = (props: OrderListTableProps) => {
|
||||||
let orders = props.orders;
|
let orders = props.orders;
|
||||||
|
|
||||||
const [showCanceledOrders, setShowCanceledOrders] = useState(false);
|
const [showCanceledOrders, setShowCanceledOrders] = useState(false);
|
||||||
|
const [limit, setLimit] = useState(props.limit || 5);
|
||||||
|
|
||||||
if (!showCanceledOrders) {
|
if (!showCanceledOrders) {
|
||||||
orders = orders.filter((order: Order) => {
|
orders = orders.filter((order: Order) => {
|
||||||
|
@ -17,6 +20,10 @@ const OrderListTable = (props: OrderListTableProps) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (orders.length > limit) {
|
||||||
|
orders = orders.slice(0, limit)
|
||||||
|
}
|
||||||
|
|
||||||
const rows = orders.map((order: Order) => (
|
const rows = orders.map((order: Order) => (
|
||||||
<tr key={order.order_id} onClick={(e) => {
|
<tr key={order.order_id} onClick={(e) => {
|
||||||
props.onClick ? props.onClick(order) : null;
|
props.onClick ? props.onClick(order) : null;
|
||||||
|
@ -41,7 +48,9 @@ const OrderListTable = (props: OrderListTableProps) => {
|
||||||
<Group>
|
<Group>
|
||||||
<Checkbox label="Show Canceled" checked={showCanceledOrders}
|
<Checkbox label="Show Canceled" checked={showCanceledOrders}
|
||||||
onChange={(event) => setShowCanceledOrders(event.currentTarget.checked)}/>
|
onChange={(event) => setShowCanceledOrders(event.currentTarget.checked)}/>
|
||||||
|
<Button onClick={() => {
|
||||||
|
setLimit(limit + 500)
|
||||||
|
}}>Load More</Button>
|
||||||
</Group>
|
</Group>
|
||||||
<Table highlightOnHover striped>
|
<Table highlightOnHover striped>
|
||||||
<thead>
|
<thead>
|
||||||
|
|
|
@ -10,7 +10,7 @@ $react-time-range--track--disabled: repeating-linear-gradient( -45deg, transpare
|
||||||
|
|
||||||
.react_time_range__time_range_container {
|
.react_time_range__time_range_container {
|
||||||
padding: 30px 52px 0 52px;
|
padding: 30px 52px 0 52px;
|
||||||
height: 70px;
|
height: 90px;
|
||||||
// width: 90%;
|
// width: 90%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user