aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/containers
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-10-20 04:42:42 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-10-20 04:42:42 +0800
commit17b282b1d743c83a4a4378eb71df098949569bdd (patch)
tree9906016f23e746421a626277827d9fae2d20d390 /packages/instant/src/containers
parent48dd9569f7d8dac398c4af629c6efa2738aec285 (diff)
downloaddexon-sol-tools-17b282b1d743c83a4a4378eb71df098949569bdd.tar
dexon-sol-tools-17b282b1d743c83a4a4378eb71df098949569bdd.tar.gz
dexon-sol-tools-17b282b1d743c83a4a4378eb71df098949569bdd.tar.bz2
dexon-sol-tools-17b282b1d743c83a4a4378eb71df098949569bdd.tar.lz
dexon-sol-tools-17b282b1d743c83a4a4378eb71df098949569bdd.tar.xz
dexon-sol-tools-17b282b1d743c83a4a4378eb71df098949569bdd.tar.zst
dexon-sol-tools-17b282b1d743c83a4a4378eb71df098949569bdd.zip
wip: retry button
Diffstat (limited to 'packages/instant/src/containers')
-rw-r--r--packages/instant/src/containers/selected_asset_buy_button.ts29
1 files changed, 8 insertions, 21 deletions
diff --git a/packages/instant/src/containers/selected_asset_buy_button.ts b/packages/instant/src/containers/selected_asset_buy_button.ts
index 99f971321..a5fa0aa8e 100644
--- a/packages/instant/src/containers/selected_asset_buy_button.ts
+++ b/packages/instant/src/containers/selected_asset_buy_button.ts
@@ -1,3 +1,4 @@
+// TODO: Rename to SelectedAssetButton
import { AssetBuyer, BuyQuote } from '@0x/asset-buyer';
import * as _ from 'lodash';
import * as React from 'react';
@@ -8,45 +9,31 @@ import { Action, actions } from '../redux/actions';
import { State } from '../redux/reducer';
import { AsyncProcessState } from '../types';
-import { BuyButton } from '../components/buy_button';
+import { AssetButton } from '../components/asset_button';
+// TODO: rename
export interface SelectedAssetBuyButtonProps {}
interface ConnectedState {
assetBuyer?: AssetBuyer;
- text: string;
+ buyOrderState: AsyncProcessState;
buyQuote?: BuyQuote;
}
interface ConnectedDispatch {
- onClick: (buyQuote: BuyQuote) => void;
+ onBuyClick: (buyQuote: BuyQuote) => void;
onBuySuccess: (buyQuote: BuyQuote) => void;
onBuyFailure: (buyQuote: BuyQuote) => void;
}
-const textForState = (state: AsyncProcessState): string => {
- switch (state) {
- case AsyncProcessState.NONE:
- return 'Buy';
- case AsyncProcessState.PENDING:
- return '...Loading';
- case AsyncProcessState.SUCCESS:
- return 'Success!';
- case AsyncProcessState.FAILURE:
- return 'Failed';
- default:
- return 'Buy';
- }
-};
-
const mapStateToProps = (state: State, _ownProps: SelectedAssetBuyButtonProps): ConnectedState => ({
assetBuyer: state.assetBuyer,
- text: textForState(state.buyOrderState),
+ buyOrderState: state.buyOrderState,
buyQuote: state.latestBuyQuote,
});
const mapDispatchToProps = (dispatch: Dispatch<Action>, ownProps: SelectedAssetBuyButtonProps): ConnectedDispatch => ({
- onClick: buyQuote => dispatch(actions.updatebuyOrderState(AsyncProcessState.PENDING)),
+ onBuyClick: buyQuote => dispatch(actions.updatebuyOrderState(AsyncProcessState.PENDING)),
onBuySuccess: buyQuote => dispatch(actions.updatebuyOrderState(AsyncProcessState.SUCCESS)),
onBuyFailure: buyQuote => dispatch(actions.updatebuyOrderState(AsyncProcessState.FAILURE)),
});
@@ -54,4 +41,4 @@ const mapDispatchToProps = (dispatch: Dispatch<Action>, ownProps: SelectedAssetB
export const SelectedAssetBuyButton: React.ComponentClass<SelectedAssetBuyButtonProps> = connect(
mapStateToProps,
mapDispatchToProps,
-)(BuyButton);
+)(AssetButton);