aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/containers
diff options
context:
space:
mode:
authorSteve Klebanoff <steve@0xproject.com>2018-11-21 07:08:27 +0800
committerGitHub <noreply@github.com>2018-11-21 07:08:27 +0800
commit15f05733be45e05974972c80c4fa8437a62633e2 (patch)
tree2f1ca2cec58e784df8bb41c37089e4336c82a77e /packages/instant/src/containers
parent7741edbbcc0d6a4d8909749ee54e502c5aaf66bf (diff)
parentb7eb2e887d636e2ed61eade4bae01596dba4b4c2 (diff)
downloaddexon-sol-tools-15f05733be45e05974972c80c4fa8437a62633e2.tar
dexon-sol-tools-15f05733be45e05974972c80c4fa8437a62633e2.tar.gz
dexon-sol-tools-15f05733be45e05974972c80c4fa8437a62633e2.tar.bz2
dexon-sol-tools-15f05733be45e05974972c80c4fa8437a62633e2.tar.lz
dexon-sol-tools-15f05733be45e05974972c80c4fa8437a62633e2.tar.xz
dexon-sol-tools-15f05733be45e05974972c80c4fa8437a62633e2.tar.zst
dexon-sol-tools-15f05733be45e05974972c80c4fa8437a62633e2.zip
Merge pull request #1290 from 0xProject/fix/instant/disable-token-picker
[instant] Don't allow changing of assets when order in progress
Diffstat (limited to 'packages/instant/src/containers')
-rw-r--r--packages/instant/src/containers/selected_erc20_asset_amount_input.ts18
1 files changed, 13 insertions, 5 deletions
diff --git a/packages/instant/src/containers/selected_erc20_asset_amount_input.ts b/packages/instant/src/containers/selected_erc20_asset_amount_input.ts
index 2c2661e1a..a39bc46a2 100644
--- a/packages/instant/src/containers/selected_erc20_asset_amount_input.ts
+++ b/packages/instant/src/containers/selected_erc20_asset_amount_input.ts
@@ -23,9 +23,10 @@ interface ConnectedState {
assetBuyer: AssetBuyer;
value?: BigNumber;
asset?: ERC20Asset;
- isDisabled: boolean;
+ isInputDisabled: boolean;
numberOfAssetsAvailable?: number;
affiliateInfo?: AffiliateInfo;
+ canSelectOtherAsset: boolean;
}
interface ConnectedDispatch {
@@ -43,21 +44,27 @@ type FinalProps = ConnectedProps & SelectedERC20AssetAmountInputProps;
const mapStateToProps = (state: State, _ownProps: SelectedERC20AssetAmountInputProps): ConnectedState => {
const processState = state.buyOrderState.processState;
- const isEnabled = processState === OrderProcessState.None || processState === OrderProcessState.Failure;
- const isDisabled = !isEnabled;
+ const isInputEnabled = processState === OrderProcessState.None || processState === OrderProcessState.Failure;
+ const isInputDisabled = !isInputEnabled;
const selectedAsset =
!_.isUndefined(state.selectedAsset) && state.selectedAsset.metaData.assetProxyId === AssetProxyId.ERC20
? (state.selectedAsset as ERC20Asset)
: undefined;
const numberOfAssetsAvailable = _.isUndefined(state.availableAssets) ? undefined : state.availableAssets.length;
+ const canSelectOtherAsset =
+ numberOfAssetsAvailable && numberOfAssetsAvailable > 1
+ ? isInputEnabled || processState === OrderProcessState.Success
+ : false;
+
const assetBuyer = state.providerState.assetBuyer;
return {
assetBuyer,
value: state.selectedAssetUnitAmount,
asset: selectedAsset,
- isDisabled,
+ isInputDisabled,
numberOfAssetsAvailable,
affiliateInfo: state.affiliateInfo,
+ canSelectOtherAsset,
};
};
@@ -102,8 +109,9 @@ const mergeProps = (
onChange: (value, asset) => {
connectedDispatch.updateBuyQuote(connectedState.assetBuyer, value, asset, connectedState.affiliateInfo);
},
- isDisabled: connectedState.isDisabled,
+ isInputDisabled: connectedState.isInputDisabled,
numberOfAssetsAvailable: connectedState.numberOfAssetsAvailable,
+ canSelectOtherAsset: connectedState.canSelectOtherAsset,
};
};