Skip to content

Commit

Permalink
fix(Coinify): setEffectiveMax func for sell
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Welber committed May 30, 2018
1 parent e710f32 commit 42f53d0
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const TradeItem = props => {
const { conversion, handleClick, handleFinish, handleTradeCancel, trade, status, cancelTradeId } = props
const receiveAmount = trade.isBuy ? trade.receiveAmount : Exchange.displayFiatToFiat({ value: trade.receiveAmount })
const exchangeAmount = trade.isBuy ? Exchange.displayFiatToFiat({ value: trade.sendAmount / conversion.buy }) : trade.sendAmount / conversion.sell
const canCancel = trade.state === 'awaiting_transfer_in'
const canCancel = trade.isBuy && trade.state === 'awaiting_transfer_in'

return (
<TableRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import QuoteInput from './QuoteInput'
import { MethodContainer } from 'components/BuySell/styled.js'

const OrderCheckout = ({ quoteR, rateQuoteR, account, onFetchQuote, reason, limits, checkoutError,
type, defaultCurrency, symbol, checkoutBusy, busy, setMax, setMin, increaseLimit, onOrderCheckoutSubmit }) => {
type, defaultCurrency, symbol, checkoutBusy, busy, setMax, setEffectiveMax, setMin, increaseLimit, onOrderCheckoutSubmit }) => {
const quoteInputSpec = {
method: type, // buy or sell
input: defaultCurrency,
Expand Down Expand Up @@ -74,6 +74,7 @@ const OrderCheckout = ({ quoteR, rateQuoteR, account, onFetchQuote, reason, limi
defaultCurrency={defaultCurrency}
symbol={symbol}
setMax={setMax}
setEffectiveMax={setEffectiveMax}
setMin={setMin}
increaseLimit={increaseLimit}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Loading from 'components/BuySell/Loading'

class QuoteInput extends Component {
render () {
const { data, symbol, setMax, setMin, checkoutError, increaseLimit, defaultCurrency, limits, disabled, type } = this.props
const { data, symbol, setMax, setEffectiveMax, setMin, checkoutError, increaseLimit, defaultCurrency, limits, disabled, type } = this.props
return data.cata({
Success: (value) => {
const QuoteInputTemplate = type === 'buy' ? QuoteInputTemplateBuy : QuoteInputTemplateSell
Expand All @@ -23,6 +23,7 @@ class QuoteInput extends Component {
defaultCurrency={defaultCurrency}
symbol={symbol}
setMax={setMax}
setEffectiveMax={setEffectiveMax}
setMin={setMin}
checkoutError={checkoutError}
increaseLimit={increaseLimit}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const getLimitsError = (errorType, limits, symbol, setMin) => {
}

const FiatConvertor = (props) => {
const { val, disabled, setMax, setMin, limits, checkoutError, defaultCurrency, symbol, increaseLimit } = props
const { val, disabled, setMax, setEffectiveMax, setMin, limits, checkoutError, defaultCurrency, symbol, increaseLimit, form } = props
const currency = 'BTC'
const level = val.level || { name: 1 }
const kyc = val.kycs.length && head(val.kycs)
Expand All @@ -111,7 +111,11 @@ const FiatConvertor = (props) => {
} else {
return (
<LimitsHelper>
<FormattedMessage id='buy.quote_input.remaining_buy_limit' defaultMessage='Your remaining buy limit is {max}' values={{ max: <a onClick={() => setMax(limits.max)}>{symbol}{limits.max}</a> }} />
{
form === 'coinifyCheckoutBuy'
? <FormattedMessage id='buy.quote_input.remaining_buy_limit' defaultMessage='Your remaining buy limit is {max}' values={{ max: <a onClick={() => setMax(limits.max)}>{symbol}{limits.max}</a> }} />
: <FormattedMessage id='sell.quote_input.remaining_sell_limit' defaultMessage='Your remaining sell limit is {max}' values={{ max: <a onClick={() => setEffectiveMax(limits.effectiveMax)}>{limits.effectiveMax / 1e8} BTC</a> }} />
}
{
level.name < 2 && kyc.state !== 'reviewing'
? <FormattedMessage id='buy.quote_input.increase_limits' defaultMessage='{increase}' values={{ increase: <a onClick={() => increaseLimit()}>Increase your limit.</a> }} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class SellContainer extends React.Component {
currency={currency}
checkoutBusy={checkoutBusy}
setMax={(amt) => formActions.change('coinifyCheckoutSell', 'leftVal', amt)}
setEffectiveMax={(btcAmt) => formActions.change('coinifyCheckoutSell', 'rightVal', (btcAmt / 1e8))}
setMin={(amt) => formActions.change('coinifyCheckoutSell', 'leftVal', amt)}
paymentMedium={paymentMedium}
initiateSell={this.startSell}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const Sell = props => {
rateQuoteR,
checkoutBusy,
setMax,
setEffectiveMax,
setMin,
paymentMedium,
initiateSell,
Expand Down Expand Up @@ -74,6 +75,7 @@ const Sell = props => {
symbol={symbol}
checkoutBusy={checkoutBusy}
setMax={setMax}
setEffectiveMax={setEffectiveMax}
setMin={setMin}
onOrderCheckoutSubmit={onOrderCheckoutSubmit}
checkoutError={checkoutError}
Expand Down

0 comments on commit 42f53d0

Please sign in to comment.