-
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(simple buy): add linked cards to settings
- Loading branch information
Philip London
committed
Apr 27, 2020
1 parent
4a53492
commit 1f17a1b
Showing
13 changed files
with
154 additions
and
46 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
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
46 changes: 46 additions & 0 deletions
46
packages/blockchain-wallet-v4-frontend/src/scenes/Settings/General/LinkedCards/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,46 @@ | ||
import { actions } from 'data' | ||
import { bindActionCreators, Dispatch } from 'redux' | ||
import { connect, ConnectedProps } from 'react-redux' | ||
import { getData } from './selectors' | ||
import { RemoteDataType, SBCardType } from 'core/types' | ||
import { RootState } from 'data/rootReducer' | ||
import React, { PureComponent } from 'react' | ||
import Success from './template.success' | ||
|
||
class LinkedCards extends PureComponent<Props> { | ||
componentDidMount () { | ||
this.props.simpleBuyActions.fetchSBCards() | ||
} | ||
|
||
render () { | ||
return this.props.data.cata({ | ||
Success: val => <Success {...val} />, | ||
Loading: () => null, | ||
Failure: () => null, | ||
NotAsked: () => null | ||
}) | ||
} | ||
} | ||
|
||
const mapStateToProps = (state: RootState): LinkStatePropsType => ({ | ||
data: getData(state) | ||
}) | ||
|
||
const mapDispatchToProps = (dispatch: Dispatch) => ({ | ||
simpleBuyActions: bindActionCreators(actions.components.simpleBuy, dispatch) | ||
}) | ||
|
||
const connector = connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
) | ||
|
||
export type SuccessStateType = { | ||
cards: Array<SBCardType> | ||
} | ||
type LinkStatePropsType = { | ||
data: RemoteDataType<string, SuccessStateType> | ||
} | ||
type Props = ConnectedProps<typeof connector> | ||
|
||
export default connector(LinkedCards) |
9 changes: 9 additions & 0 deletions
9
packages/blockchain-wallet-v4-frontend/src/scenes/Settings/General/LinkedCards/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,9 @@ | ||
import { lift } from 'ramda' | ||
import { RootState } from 'data/rootReducer' | ||
import { selectors } from 'data' | ||
|
||
export const getData = (state: RootState) => { | ||
const cardsR = selectors.components.simpleBuy.getSBCards(state) | ||
|
||
return lift(cards => ({ cards }))(cardsR) | ||
} |
42 changes: 42 additions & 0 deletions
42
...lockchain-wallet-v4-frontend/src/scenes/Settings/General/LinkedCards/template.success.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,42 @@ | ||
import { Button } from 'blockchain-info-components' | ||
import { FormattedMessage } from 'react-intl' | ||
import { | ||
SettingComponent, | ||
SettingContainer, | ||
SettingHeader, | ||
SettingSummary | ||
} from 'components/Setting' | ||
import { SuccessStateType } from '.' | ||
import React from 'react' | ||
|
||
const Success: React.FC<Props> = props => { | ||
return ( | ||
<SettingContainer> | ||
<SettingSummary> | ||
<SettingHeader> | ||
<FormattedMessage | ||
id='scenes.settings.linked_cards' | ||
defaultMessage='Linked Cards' | ||
/> | ||
</SettingHeader> | ||
{props.cards.map((card, i) => { | ||
return ( | ||
<div key={i}>{card.state === 'ACTIVE' ? card.card.number : ''}</div> | ||
) | ||
})} | ||
</SettingSummary> | ||
<SettingComponent> | ||
<Button nature='empty' data-e2e='addCardFromSettings'> | ||
<FormattedMessage | ||
id='scenes.lockbox.settings.adddevice.add' | ||
defaultMessage='Add Device' | ||
/> | ||
</Button> | ||
</SettingComponent> | ||
</SettingContainer> | ||
) | ||
} | ||
|
||
type Props = SuccessStateType | ||
|
||
export default Success |
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
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