-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Jumio): add pending trade balance
- Loading branch information
plondon
committed
Jul 24, 2018
1 parent
afd4c08
commit 1bceb61
Showing
4 changed files
with
97 additions
and
3 deletions.
There are no files selected for viewing
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,22 @@ | ||
import { selectors } from 'data' | ||
import { add, compose, filter, reduce, pathOr } from 'ramda' | ||
import { Exchange } from 'blockchain-wallet-v4/src' | ||
|
||
const isBuyProcessing = trade => trade.isBuy && trade.state === 'processing' | ||
|
||
const extractPendingBalance = trades => { | ||
const pendingBuyTrades = compose(filter(isBuyProcessing))(trades) | ||
const pendingAmounts = pendingBuyTrades.map(x => | ||
pathOr(0, ['receiveAmount'], x) | ||
) | ||
return Exchange.convertBitcoinToBitcoin({ | ||
value: reduce(add, 0, pendingAmounts), | ||
fromUnit: 'BTC', | ||
toUnit: 'SAT' | ||
}).value | ||
} | ||
|
||
export const getData = state => { | ||
const tradesR = selectors.core.data.sfox.getTrades(state) | ||
return tradesR.map(extractPendingBalance) | ||
} |
21 changes: 21 additions & 0 deletions
21
...let-v4-frontend/src/layouts/Wallet/MenuTop/Balance/SfoxPendingBalance/template.loading.js
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,21 @@ | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
|
||
import { FlatLoader } from 'blockchain-info-components' | ||
|
||
const Wrapper = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 5px; | ||
box-sizing: border-box; | ||
` | ||
|
||
export default props => { | ||
return ( | ||
<Wrapper> | ||
<FlatLoader width='50px' height='14px' /> | ||
</Wrapper> | ||
) | ||
} |
52 changes: 52 additions & 0 deletions
52
...let-v4-frontend/src/layouts/Wallet/MenuTop/Balance/SfoxPendingBalance/template.success.js
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,52 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import styled from 'styled-components' | ||
import FiatDisplay from 'components/Display/FiatDisplay' | ||
import { LinkContainer } from 'react-router-bootstrap' | ||
import { FormattedMessage } from 'react-intl' | ||
import { Banner, Text } from 'blockchain-info-components' | ||
|
||
const Wrapper = styled.div` | ||
display: inline-flex; | ||
flex-direction: row; | ||
align-items: center; | ||
padding-left: 5px; | ||
margin-bottom: 10px; | ||
padding-right: ${props => (props.large ? '15px' : '25px')}; | ||
> div:last-child { | ||
margin-left: 10px; | ||
> div { | ||
color: ${props => props.theme['gray-3']}; | ||
} | ||
} | ||
` | ||
|
||
const Success = props => { | ||
return props.balance === 0 ? null : ( | ||
<LinkContainer to='/buy-sell'> | ||
<Wrapper> | ||
<Text size='10px' weight={300}> | ||
BTC | ||
</Text> | ||
<Banner inline> | ||
<FiatDisplay coin='BTC' cursor='pointer' size='10px' weight={300}> | ||
{props.balance} | ||
</FiatDisplay> | ||
<span> </span> | ||
<Text size='10px' weight={300}> | ||
<FormattedMessage | ||
id='scenes.wallet.menutop.balance.sfoxpendingbalance' | ||
defaultMessage='Pending Balance' | ||
/> | ||
</Text> | ||
</Banner> | ||
</Wrapper> | ||
</LinkContainer> | ||
) | ||
} | ||
|
||
Success.propTypes = { | ||
balance: PropTypes.number.isRequired | ||
} | ||
|
||
export default Success |