-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#29 Display open orders for all outcomes
- Loading branch information
Showing
9 changed files
with
269 additions
and
180 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,30 @@ | ||
import React from 'react'; | ||
|
||
import OpenOrder from '../../open-orders/components/open-order'; | ||
import OpenOrdersGroup from '../../open-orders/components/open-orders-group'; | ||
|
||
const OpenOrders = (p) => ( | ||
<div className="open-orders"> | ||
<table> | ||
<tbody> | ||
<tr> | ||
<th>Type</th> | ||
<th>Shares</th> | ||
<th>Price</th> | ||
<th>Matched</th> | ||
<th>Unmatched</th> | ||
<th> </th> | ||
</tr> | ||
{ | ||
p.openOrders.items.map(openOrder => ( | ||
<OpenOrder | ||
key={openOrder.id} | ||
{...openOrder} | ||
onCancelOrder={p.openOrders.onCancelOrder} | ||
<h2>Open orders</h2> | ||
{ | ||
p.outcomes.map(outcome => { | ||
if (outcome.openOrders.items.length > 0) { | ||
return ( | ||
<OpenOrdersGroup | ||
key={outcome.id} | ||
name={outcome.name} | ||
openOrders={outcome.openOrders} | ||
/> | ||
) | ||
) | ||
} else { | ||
return (<div>No open orders</div>); | ||
} | ||
</tbody> | ||
<tfoot> | ||
{ | ||
p.openOrders.items.length > 0 && | ||
<button className="button" onClick={(event) => { p.openOrders.onCancelAllOrders(); }}> | ||
Cancel all | ||
</button> | ||
} | ||
{ | ||
p.openOrders.bidsCount > 0 && | ||
<button className="button" onClick={(event) => { p.openOrders.onCancelAllBids(); }}> | ||
Cancel all bids | ||
</button> | ||
} | ||
{ | ||
p.openOrders.asksCount > 0 && | ||
<button className="button" onClick={(event) => { p.openOrders.onCancelAllAsks(); }}> | ||
Cancel all asks | ||
</button> | ||
} | ||
</tfoot> | ||
</table> | ||
}) | ||
} | ||
</div> | ||
); | ||
|
||
OpenOrders.propTypes = { | ||
openOrders: React.PropTypes.object | ||
outcomes: React.PropTypes.array | ||
}; | ||
|
||
export default OpenOrders; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Author: priecint | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import Collapse from '../../common/components/collapse'; | ||
import Clickable from '../../common/components/clickable'; | ||
|
||
import OpenOrder from '../../open-orders/components/open-order'; | ||
|
||
const OpenOrdersGroup = (p) => ( | ||
<div> | ||
<Clickable component="h3" onClick={(event) => p.openOrders.toggleGroupOpen()}> | ||
{p.name} | ||
</Clickable> | ||
|
||
<Collapse isOpen={p.openOrders.isMarketOpenOrdersOpen}> | ||
<table> | ||
<tbody> | ||
<tr> | ||
<th>Type</th> | ||
<th>Shares</th> | ||
<th>Price</th> | ||
<th>Matched</th> | ||
<th>Unmatched</th> | ||
<th> </th> | ||
</tr> | ||
{ | ||
p.openOrders.items.map(openOrder => ( | ||
<OpenOrder | ||
key={openOrder.id} | ||
{...openOrder} | ||
onCancelOrder={p.openOrders.onCancelOrder} | ||
/> | ||
) | ||
) | ||
} | ||
</tbody> | ||
<tfoot> | ||
<tr> | ||
<td colSpan="5"> | ||
{ | ||
p.openOrders.items.length > 0 && | ||
<button className="button" onClick={(event) => { | ||
p.openOrders.onCancelAllOrders(); | ||
}}> | ||
Cancel all | ||
</button> | ||
} | ||
{ | ||
p.openOrders.bidsCount > 0 && | ||
<button className="button" onClick={(event) => { | ||
p.openOrders.onCancelAllBids(); | ||
}}> | ||
Cancel all bids | ||
</button> | ||
} | ||
{ | ||
p.openOrders.asksCount > 0 && | ||
<button className="button" onClick={(event) => { | ||
p.openOrders.onCancelAllAsks(); | ||
}}> | ||
Cancel all asks | ||
</button> | ||
} | ||
</td> | ||
</tr> | ||
</tfoot> | ||
</table> | ||
</Collapse> | ||
</div> | ||
); | ||
|
||
OpenOrdersGroup.propTypes = { | ||
openOrders: React.PropTypes.object, | ||
name: React.PropTypes.string | ||
}; | ||
|
||
export default OpenOrdersGroup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
.market { | ||
.open-orders { | ||
padding: 4vmin 6vmin; | ||
} | ||
|
||
.open-order:not(:hover) .cancel-order-action { | ||
display: none; | ||
} | ||
.open-order { | ||
height: 27px; // same height as when action is visible | ||
} | ||
|
||
.open-order:not(:hover) .cancel-order-action { | ||
display: none; | ||
} | ||
|
||
.open-order.isCancelling { | ||
text-decoration: line-through; | ||
} | ||
.open-order.isCancelling { | ||
text-decoration: line-through; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.