Skip to content

Commit

Permalink
added sort for orders table
Browse files Browse the repository at this point in the history
  • Loading branch information
lzhabo committed Feb 22, 2024
1 parent 138056b commit 523fbda
Showing 1 changed file with 46 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,50 +100,54 @@ const BottomTablesInterfaceSpotImpl: React.FC<IProps> = observer(() => {
};

const getOrderData = () =>
vm.myOrders.map((order) => ({
date: order.timestamp.format("DD MMM YY, HH:mm"),
pair: order.marketSymbol,
type: (
<TableText color={order.type === "SELL" ? theme.colors.redLight : theme.colors.greenLight}>
{order.type}
</TableText>
),
amount: (
<SmartFlex center="y" gap="4px">
<TableText primary>{order.baseSizeUnits.toSignificant(2)}</TableText>
<TokenBadge>
<Text>{order.baseToken.symbol}</Text>
</TokenBadge>
</SmartFlex>
),
price: toCurrency(order.priceUnits.toSignificant(2)),
action: (
<CancelButton onClick={() => vm.cancelOrder(order.id)}>
{vm.isOrderCancelling ? "Loading..." : "Cancel"}
</CancelButton>
),
}));
vm.myOrders
.sort((a, b) => b.timestamp.valueOf() - a.timestamp.valueOf())
.map((order) => ({
date: order.timestamp.format("DD MMM YY, HH:mm"),
pair: order.marketSymbol,
type: (
<TableText color={order.type === "SELL" ? theme.colors.redLight : theme.colors.greenLight}>
{order.type}
</TableText>
),
amount: (
<SmartFlex center="y" gap="4px">
<TableText primary>{order.baseSizeUnits.toSignificant(2)}</TableText>
<TokenBadge>
<Text>{order.baseToken.symbol}</Text>
</TokenBadge>
</SmartFlex>
),
price: toCurrency(order.priceUnits.toSignificant(2)),
action: (
<CancelButton onClick={() => vm.cancelOrder(order.id)}>
{vm.isOrderCancelling ? "Loading..." : "Cancel"}
</CancelButton>
),
}));

const getHistoryData = () =>
vm.myOrdersHistory.map((order) => ({
date: order.timestamp.format("DD MMM YY, HH:mm"),
pair: order.marketSymbol,
type: (
<TableText color={order.type === "SELL" ? theme.colors.redLight : theme.colors.greenLight}>
{order.type}
</TableText>
),
amount: (
<SmartFlex center="y" gap="4px">
<TableText primary>{order.formatTradeAmount}</TableText>
<TokenBadge>
<Text>{order.baseToken.symbol}</Text>
</TokenBadge>
</SmartFlex>
),
price: toCurrency(order.formatPrice),
filled: order.formatTradeAmount,
}));
vm.myOrdersHistory
.sort((a, b) => b.timestamp.valueOf() - a.timestamp.valueOf())
.map((order) => ({
date: order.timestamp.format("DD MMM YY, HH:mm"),
pair: order.marketSymbol,
type: (
<TableText color={order.type === "SELL" ? theme.colors.redLight : theme.colors.greenLight}>
{order.type}
</TableText>
),
amount: (
<SmartFlex center="y" gap="4px">
<TableText primary>{order.formatTradeAmount}</TableText>
<TokenBadge>
<Text>{order.baseToken.symbol}</Text>
</TokenBadge>
</SmartFlex>
),
price: toCurrency(order.formatPrice),
filled: order.formatTradeAmount,
}));

const getBalanceData = () =>
Array.from(balanceStore.balances)
Expand Down

0 comments on commit 523fbda

Please sign in to comment.