diff options
Diffstat (limited to 'packages/instant/src/containers')
3 files changed, 22 insertions, 41 deletions
diff --git a/packages/instant/src/containers/selected_asset_button.tsx b/packages/instant/src/containers/selected_asset_button.tsx deleted file mode 100644 index d368d05e1..000000000 --- a/packages/instant/src/containers/selected_asset_button.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import * as _ from 'lodash'; -import * as React from 'react'; -import { connect } from 'react-redux'; - -import { SecondaryButton } from '../components/secondary_button'; -import { State } from '../redux/reducer'; -import { AsyncProcessState, OrderState } from '../types'; - -import { PlacingOrderButton } from '../components/placing_order_button'; - -import { SelectedAssetBuyButton } from './selected_asset_buy_button'; -import { SelectedAssetRetryButton } from './selected_asset_retry_button'; -import { SelectedAssetViewTransactionButton } from './selected_asset_view_transaction_button'; - -interface ConnectedState { - buyOrderState: OrderState; -} -export interface SelectedAssetButtonProps {} -const mapStateToProps = (state: State, _ownProps: SelectedAssetButtonProps): ConnectedState => ({ - buyOrderState: state.buyOrderState, -}); - -const SelectedAssetButtonPresentationComponent: React.StatelessComponent<{ - buyOrderState: OrderState; -}> = props => { - if (props.buyOrderState.processState === AsyncProcessState.FAILURE) { - return <SelectedAssetRetryButton />; - } else if (props.buyOrderState.processState === AsyncProcessState.SUCCESS) { - return <SelectedAssetViewTransactionButton />; - } else if (props.buyOrderState.processState === AsyncProcessState.PENDING) { - return <PlacingOrderButton />; - } - - return <SelectedAssetBuyButton />; -}; - -export const SelectedAssetButton: React.ComponentClass<SelectedAssetButtonProps> = connect(mapStateToProps)( - SelectedAssetButtonPresentationComponent, -); diff --git a/packages/instant/src/containers/selected_asset_buy_order_state_button.tsx b/packages/instant/src/containers/selected_asset_buy_order_state_button.tsx new file mode 100644 index 000000000..f3efbb5d2 --- /dev/null +++ b/packages/instant/src/containers/selected_asset_buy_order_state_button.tsx @@ -0,0 +1,20 @@ +import * as _ from 'lodash'; +import * as React from 'react'; +import { connect } from 'react-redux'; + +import { State } from '../redux/reducer'; +import { AsyncProcessState } from '../types'; + +import { BuyOrderStateButton } from '../components/buy_order_state_button'; + +interface ConnectedState { + buyOrderProcessingState: AsyncProcessState; +} +export interface SelectedAssetButtonProps {} +const mapStateToProps = (state: State, _ownProps: SelectedAssetButtonProps): ConnectedState => ({ + buyOrderProcessingState: state.buyOrderState.processState, +}); + +export const SelectedAssetBuyOrderStateButton: React.ComponentClass<SelectedAssetButtonProps> = connect( + mapStateToProps, +)(BuyOrderStateButton); diff --git a/packages/instant/src/containers/selected_asset_retry_button.tsx b/packages/instant/src/containers/selected_asset_retry_button.tsx index 66177551d..b2b140be6 100644 --- a/packages/instant/src/containers/selected_asset_retry_button.tsx +++ b/packages/instant/src/containers/selected_asset_retry_button.tsx @@ -17,10 +17,10 @@ const mapDispatchToProps = ( dispatch: Dispatch<Action>, _ownProps: SelectedAssetRetryButtonProps, ): ConnectedDispatch => ({ - onClick: () => dispatch(actions.clearBuyQuoteAndSelectedAssetAmount()), + onClick: () => dispatch(actions.resetAmount()), }); export const SelectedAssetRetryButton: React.ComponentClass<SelectedAssetRetryButtonProps> = connect( - null, + undefined, mapDispatchToProps, )(RetryButton); |