-
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(sell p3): add back balance movement
- Loading branch information
Philip London
committed
Nov 18, 2020
1 parent
d6d2686
commit c4729b2
Showing
3 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
...v4-frontend/src/modals/SimpleBuy/CryptoSelection/CryptoSelector/BalanceMovement/index.tsx
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,69 @@ | ||
import { CoinType } from 'core/types' | ||
import { connect, ConnectedProps } from 'react-redux' | ||
import { getData } from './selectors' | ||
import { RootState } from 'data/rootReducer' | ||
import { SkeletonRectangle } from 'blockchain-info-components' | ||
import CoinDisplay from 'components/Display/CoinDisplay' | ||
import FiatDisplay from 'components/Display/FiatDisplay' | ||
import React, { PureComponent } from 'react' | ||
import styled from 'styled-components' | ||
|
||
const Container = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
` | ||
const FiatDisplayTitle = styled(FiatDisplay)` | ||
display: flex; | ||
align-items: center; | ||
` | ||
const CoinDisplayTitle = styled(CoinDisplay)` | ||
display: flex; | ||
margin-left: 4px; | ||
` | ||
|
||
class BalancesMovement extends PureComponent<Props, State> { | ||
render () { | ||
return this.props.data.cata({ | ||
Success: val => ( | ||
<Container> | ||
<FiatDisplayTitle | ||
coin={this.props.coin} | ||
size='14px' | ||
weight={500} | ||
color='grey800' | ||
> | ||
{val.balances[this.props.coin]?.available} | ||
</FiatDisplayTitle> | ||
<CoinDisplayTitle | ||
coin={this.props.coin} | ||
size='14px' | ||
weight={500} | ||
color='grey600' | ||
> | ||
{val.balances[this.props.coin]?.available} | ||
</CoinDisplayTitle> | ||
</Container> | ||
), | ||
Loading: () => <SkeletonRectangle height={'12px'} width={'40px'} />, | ||
Failure: () => null, | ||
NotAsked: () => null | ||
}) | ||
} | ||
} | ||
|
||
const mapStateToProps = (state: RootState) => ({ | ||
data: getData(state) | ||
}) | ||
|
||
export const mapDispatchToProps = () => ({}) | ||
|
||
const connector = connect(mapStateToProps, mapDispatchToProps) | ||
|
||
export type OwnProps = { | ||
coin: CoinType | ||
} | ||
|
||
type Props = OwnProps & ConnectedProps<typeof connector> | ||
type State = {} | ||
|
||
export default connector(BalancesMovement) |
13 changes: 13 additions & 0 deletions
13
...frontend/src/modals/SimpleBuy/CryptoSelection/CryptoSelector/BalanceMovement/selectors.ts
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,13 @@ | ||
import { ExtractSuccess } from 'core/types' | ||
import { lift } from 'ramda' | ||
import { RootState } from 'data/rootReducer' | ||
|
||
import { selectors } from 'data' | ||
|
||
export const getData = (state: RootState) => { | ||
const balancesR = selectors.components.simpleBuy.getSBBalances(state) | ||
|
||
return lift((balances: ExtractSuccess<typeof balancesR>) => ({ | ||
balances | ||
}))(balancesR) | ||
} |
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