Skip to content

Commit e222104

Browse files
committed
add undo cancel from blotter
1 parent 363e913 commit e222104

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/components/positionBlotter.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ class PositionBlotter extends Component {
2323
orderId: order.orderId,
2424
};
2525
console.log("input order to be sent: ", inputOrder);
26-
if (order.status !== "OPEN") return;
26+
const actionUrl =
27+
order.status === "CANCELLED" ? "/orders/undocancel" : "/orders/cancel";
2728
/* Post Order to server */
28-
fetch(baseUrl + "/orders/cancel", {
29+
fetch(baseUrl + actionUrl, {
2930
method: "POST",
3031
mode: "cors",
3132
cache: "no-cache",
@@ -86,8 +87,8 @@ class PositionBlotter extends Component {
8687
//check if valid message
8788
const { orders } = this.state;
8889
const orderId = msg.orderId;
89-
if ("OPEN" === msg.status) {
90-
//new trade
90+
const found = orders.find((order) => order.orderId === orderId);
91+
if (!found) {
9192
this.setState({ orders: [msg, ...orders] });
9293
} else {
9394
//Edited trade

0 commit comments

Comments
 (0)