diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-11-13 05:30:47 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-11-13 05:30:47 +0800 |
commit | 79f0324abc6e59d5595770e44d620e6d0cccd6bc (patch) | |
tree | cab441568b4362b90f2626257576ebab60b7ecbb /packages/instant/src/containers | |
parent | a8a1ea92a614181ebdf6c738139723f0d5c6da69 (diff) | |
download | dexon-sol-tools-79f0324abc6e59d5595770e44d620e6d0cccd6bc.tar dexon-sol-tools-79f0324abc6e59d5595770e44d620e6d0cccd6bc.tar.gz dexon-sol-tools-79f0324abc6e59d5595770e44d620e6d0cccd6bc.tar.bz2 dexon-sol-tools-79f0324abc6e59d5595770e44d620e6d0cccd6bc.tar.lz dexon-sol-tools-79f0324abc6e59d5595770e44d620e6d0cccd6bc.tar.xz dexon-sol-tools-79f0324abc6e59d5595770e44d620e6d0cccd6bc.tar.zst dexon-sol-tools-79f0324abc6e59d5595770e44d620e6d0cccd6bc.zip |
feat: integrate wallet flow with heartbeat and other branches
Diffstat (limited to 'packages/instant/src/containers')
-rw-r--r-- | packages/instant/src/containers/connected_account_payment_method.ts | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/packages/instant/src/containers/connected_account_payment_method.ts b/packages/instant/src/containers/connected_account_payment_method.ts index ee57d1829..c20af67cc 100644 --- a/packages/instant/src/containers/connected_account_payment_method.ts +++ b/packages/instant/src/containers/connected_account_payment_method.ts @@ -4,34 +4,61 @@ import { Dispatch } from 'redux'; import { PaymentMethod } from '../components/payment_method'; import { Action, actions } from '../redux/actions'; +import { asyncData } from '../redux/async_data'; import { State } from '../redux/reducer'; -import { Account, Network, StandardSlidingPanelContent } from '../types'; +import { Account, Network, ProviderState, StandardSlidingPanelContent } from '../types'; export interface ConnectedAccountPaymentMethodProps {} interface ConnectedState { - account: Account; network: Network; + providerState: ProviderState; } interface ConnectedDispatch { - openStandardSlidingPanel: (content: StandardSlidingPanelContent) => void; + onInstallWalletClick: () => void; + unlockWalletAndDispatchToStore: (providerState: ProviderState) => void; +} + +interface ConnectedProps { + onInstallWalletClick: () => void; + onUnlockWalletClick: () => void; + account: Account; + network: Network; } +type FinalProps = ConnectedProps & ConnectedAccountPaymentMethodProps; + const mapStateToProps = (state: State, _ownProps: ConnectedAccountPaymentMethodProps): ConnectedState => ({ - account: state.providerState.account, network: state.network, + providerState: state.providerState, }); const mapDispatchToProps = ( dispatch: Dispatch<Action>, ownProps: ConnectedAccountPaymentMethodProps, ): ConnectedDispatch => ({ - openStandardSlidingPanel: (content: StandardSlidingPanelContent) => - dispatch(actions.openStandardSlidingPanel(content)), + onInstallWalletClick: () => dispatch(actions.openStandardSlidingPanel(StandardSlidingPanelContent.InstallWallet)), + unlockWalletAndDispatchToStore: async (providerState: ProviderState) => + asyncData.fetchAccountInfoAndDispatchToStore(providerState, dispatch, true), +}); + +const mergeProps = ( + connectedState: ConnectedState, + connectedDispatch: ConnectedDispatch, + ownProps: ConnectedAccountPaymentMethodProps, +): FinalProps => ({ + ...ownProps, + network: connectedState.network, + account: connectedState.providerState.account, + onInstallWalletClick: connectedDispatch.onInstallWalletClick, + onUnlockWalletClick: () => { + connectedDispatch.unlockWalletAndDispatchToStore(connectedState.providerState); + }, }); export const ConnectedAccountPaymentMethod: React.ComponentClass<ConnectedAccountPaymentMethodProps> = connect( mapStateToProps, mapDispatchToProps, + mergeProps, )(PaymentMethod); |