-
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.
Browse files
Browse the repository at this point in the history
Open orders
- Loading branch information
Showing
22 changed files
with
712 additions
and
680 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
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
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,34 @@ | ||
import React from 'react'; | ||
|
||
import OpenOrdersSummary from '../../open-orders/components/open-orders-summary'; | ||
import OpenOrdersGroup from '../../open-orders/components/open-orders-group'; | ||
|
||
const OpenOrders = (p) => ( | ||
<div className="market-open-orders"> | ||
<OpenOrdersSummary | ||
userOpenOrdersSummary={p.userOpenOrdersSummary} | ||
/> | ||
|
||
<div className="open-orders-list"> | ||
{ | ||
p.outcomes.map(outcome => ( | ||
<OpenOrdersGroup | ||
key={outcome.id} | ||
id={outcome.id} | ||
name={outcome.name} | ||
userOpenOrders={outcome.userOpenOrders} | ||
cancelOrder={p.cancelOrder} | ||
/> | ||
)) | ||
} | ||
</div> | ||
</div> | ||
); | ||
|
||
OpenOrders.propTypes = { | ||
userOpenOrdersSummary: React.PropTypes.object, | ||
outcomes: React.PropTypes.array, | ||
cancelOrder: React.PropTypes.func.isRequired | ||
}; | ||
|
||
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
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,48 @@ | ||
/* | ||
* Author: priecint | ||
*/ | ||
|
||
import React from 'react'; | ||
import classnames from 'classnames'; | ||
|
||
import ValueDenomination from '../../common/components/value-denomination'; | ||
|
||
const OpenOrder = (p) => ( | ||
<tr className={classnames('open-order', { 'is-disabled': p.isCancelling || p.isCancelled })}> | ||
<td className="outcome-name"> | ||
{p.outcomeName} | ||
</td> | ||
<td className="type"> | ||
{p.type} | ||
</td> | ||
<td className="shares"> | ||
<ValueDenomination {...p.unmatchedShares} /> | ||
</td> | ||
<td className="price"> | ||
<ValueDenomination {...p.avgPrice} /> | ||
</td> | ||
<td className="cancel"> | ||
<button | ||
className="button cancel-order-action" | ||
disabled={p.isCancelling || p.isCancelled} | ||
title="Cancel order" | ||
onClick={(event) => { p.cancelOrder(p.id, p.marketID, p.type); }} | ||
>Cancel</button> | ||
|
||
</td> | ||
</tr> | ||
); | ||
|
||
OpenOrder.propTypes = { | ||
id: React.PropTypes.string.isRequired, | ||
marketID: React.PropTypes.string.isRequired, | ||
outcomeName: React.PropTypes.string.isRequired, | ||
type: React.PropTypes.string.isRequired, | ||
avgPrice: React.PropTypes.object.isRequired, | ||
unmatchedShares: React.PropTypes.object.isRequired, | ||
isCancelling: React.PropTypes.bool.isRequired, | ||
isCancelled: React.PropTypes.bool.isRequired, | ||
cancelOrder: React.PropTypes.func.isRequired | ||
}; | ||
|
||
export default OpenOrder; |
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,43 @@ | ||
/* | ||
* Author: priecint | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import OpenOrder from '../../open-orders/components/open-order'; | ||
|
||
const OpenOrdersGroup = (p) => { | ||
if (p.userOpenOrders == null || p.userOpenOrders.length === 0) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<table className="open-orders-group"> | ||
<tbody> | ||
<tr> | ||
<th className="outcome-name">Outcome</th> | ||
<th className="type">Type</th> | ||
<th className="shares">Shares</th> | ||
<th className="price">Price</th> | ||
<th className="cancel"> </th> | ||
</tr> | ||
{p.userOpenOrders.map(openOrder => ( | ||
<OpenOrder | ||
key={openOrder.id} | ||
outcomeName={p.name} | ||
{...openOrder} | ||
cancelOrder={p.cancelOrder} | ||
/> | ||
))} | ||
</tbody> | ||
</table> | ||
); | ||
}; | ||
|
||
OpenOrdersGroup.propTypes = { | ||
userOpenOrders: React.PropTypes.arrayOf(React.PropTypes.object).isRequired, | ||
name: React.PropTypes.string.isRequired, | ||
cancelOrder: React.PropTypes.func.isRequired | ||
}; | ||
|
||
export default OpenOrdersGroup; |
23 changes: 23 additions & 0 deletions
23
src/modules/open-orders/components/open-orders-summary.jsx
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,23 @@ | ||
/* | ||
* Author: priecint | ||
*/ | ||
|
||
import React from 'react'; | ||
import ValueDenomination from '../../common/components/value-denomination'; | ||
|
||
const OpenOrdersSummary = (p) => { | ||
const hasOpenOrders = p.userOpenOrdersSummary != null && p.userOpenOrdersSummary.openOrdersCount != null && p.userOpenOrdersSummary.openOrdersCount.value > 0; | ||
return ( | ||
<div className="market-section-header"> | ||
{ | ||
hasOpenOrders ? (<ValueDenomination {...p.userOpenOrdersSummary.openOrdersCount} />) : 'No Open Orders' | ||
} | ||
</div> | ||
); | ||
}; | ||
|
||
OpenOrdersSummary.propTypes = { | ||
userOpenOrdersSummary: React.PropTypes.object | ||
}; | ||
|
||
export default OpenOrdersSummary; |
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,73 @@ | ||
.market-open-orders { | ||
.open-orders-list { | ||
margin: 0 0 0 -1.5em; | ||
padding: 4vmin 6vmin; | ||
|
||
.open-orders-group { | ||
display: inline-block; | ||
margin: 0 0 2em 0; | ||
padding: 0 1.5em; | ||
vertical-align: top; | ||
border-right: 1px solid @color-border; | ||
|
||
td { | ||
padding: 0.1em 0.5em; | ||
} | ||
|
||
.outcome-name { | ||
min-width: 9rem; | ||
text-align: left; | ||
} | ||
.type { | ||
text-align: right; | ||
} | ||
.shares { | ||
text-align: right; | ||
} | ||
.price { | ||
text-align: right; | ||
} | ||
.cancel { | ||
padding: 0.1em 0em; | ||
text-align: left; | ||
|
||
.cancel-order-action { | ||
padding: 0; | ||
height: unset; | ||
line-height: unset; | ||
text-align: left; | ||
color: @color-danger-active; | ||
background: transparent; | ||
font-size: 0.6em; | ||
|
||
&:before { | ||
content: '\f00d'; | ||
display: inline-block; position: relative; | ||
left: -0.2em; | ||
font-family: FontAwesome; | ||
font-weight: 700; | ||
|
||
} | ||
|
||
&:hover, &:active { | ||
font-weight: 900; | ||
} | ||
|
||
&[disabled] { | ||
color: @color-muted-active !important; | ||
background: transparent !important; | ||
} | ||
} | ||
} | ||
|
||
.open-order { | ||
.outcome-name { | ||
text-transform: uppercase; | ||
} | ||
.is-disabled { | ||
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
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,27 @@ | ||
/* | ||
* Author: priecint | ||
*/ | ||
|
||
export const cancelOrder = orderId => setTimeout(() => { | ||
require('../selectors').markets.forEach((market) => { | ||
market.outcomes.forEach(outcome => { | ||
const order = outcome.userOpenOrders.find(openOrder => openOrder.id === orderId); | ||
if (order != null) { | ||
order.isCancelling = true; | ||
require('../selectors').update({}); | ||
} | ||
}); | ||
}); | ||
setTimeout(() => { | ||
require('../selectors').markets.forEach((market) => { | ||
market.outcomes.forEach(outcome => { | ||
const order = outcome.userOpenOrders.find(openOrder => openOrder.id === orderId); | ||
if (order != null) { | ||
const index = outcome.userOpenOrders.findIndex(openOrder => openOrder.id === orderId); | ||
outcome.userOpenOrders.splice(index, 1); | ||
require('../selectors').update({}); | ||
} | ||
}); | ||
}); | ||
}, 2000); | ||
}, 1); |
Oops, something went wrong.