diff options
author | Brandon Millman <brandon@0xproject.com> | 2018-12-04 04:48:42 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-04 04:48:42 +0800 |
commit | f076cdb8329693e9d7351ec88d2ac01ad42a2a3a (patch) | |
tree | 87677e557b2897422089b4a3e35fbcb6f00b89c2 /packages/instant/src/components/buy_button.tsx | |
parent | 3662ab25246a53128d85e8427ebe07518245b611 (diff) | |
parent | c52d48d4db693a71b6eecf93dde5d7cbb64c51b6 (diff) | |
download | dexon-sol-tools-f076cdb8329693e9d7351ec88d2ac01ad42a2a3a.tar dexon-sol-tools-f076cdb8329693e9d7351ec88d2ac01ad42a2a3a.tar.gz dexon-sol-tools-f076cdb8329693e9d7351ec88d2ac01ad42a2a3a.tar.bz2 dexon-sol-tools-f076cdb8329693e9d7351ec88d2ac01ad42a2a3a.tar.lz dexon-sol-tools-f076cdb8329693e9d7351ec88d2ac01ad42a2a3a.tar.xz dexon-sol-tools-f076cdb8329693e9d7351ec88d2ac01ad42a2a3a.tar.zst dexon-sol-tools-f076cdb8329693e9d7351ec88d2ac01ad42a2a3a.zip |
Merge pull request #1365 from 0xProject/fix/instant/token-selector
[instant] various polish items
Diffstat (limited to 'packages/instant/src/components/buy_button.tsx')
-rw-r--r-- | packages/instant/src/components/buy_button.tsx | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/packages/instant/src/components/buy_button.tsx b/packages/instant/src/components/buy_button.tsx index eeb42d6fc..1489b94d4 100644 --- a/packages/instant/src/components/buy_button.tsx +++ b/packages/instant/src/components/buy_button.tsx @@ -1,4 +1,5 @@ import { AssetBuyer, AssetBuyerError, BuyQuote } from '@0x/asset-buyer'; +import { AssetProxyId } from '@0x/types'; import { BigNumber } from '@0x/utils'; import { Web3Wrapper } from '@0x/web3-wrapper'; import * as _ from 'lodash'; @@ -7,7 +8,7 @@ import { oc } from 'ts-optchain'; import { WEB_3_WRAPPER_TRANSACTION_FAILED_ERROR_MSG_PREFIX } from '../constants'; import { ColorOption } from '../style/theme'; -import { AffiliateInfo, ZeroExInstantError } from '../types'; +import { AffiliateInfo, Asset, ZeroExInstantError } from '../types'; import { analytics } from '../util/analytics'; import { gasPriceEstimator } from '../util/gas_price_estimator'; import { util } from '../util/util'; @@ -21,6 +22,7 @@ export interface BuyButtonProps { assetBuyer: AssetBuyer; web3Wrapper: Web3Wrapper; affiliateInfo?: AffiliateInfo; + selectedAsset?: Asset; onValidationPending: (buyQuote: BuyQuote) => void; onValidationFail: (buyQuote: BuyQuote, errorMessage: AssetBuyerError | ZeroExInstantError) => void; onSignatureDenied: (buyQuote: BuyQuote) => void; @@ -36,8 +38,12 @@ export class BuyButton extends React.Component<BuyButtonProps> { onBuyFailure: util.boundNoop, }; public render(): React.ReactNode { - const { buyQuote, accountAddress } = this.props; + const { buyQuote, accountAddress, selectedAsset } = this.props; const shouldDisableButton = _.isUndefined(buyQuote) || _.isUndefined(accountAddress); + const buttonText = + !_.isUndefined(selectedAsset) && selectedAsset.metaData.assetProxyId === AssetProxyId.ERC20 + ? `Buy ${selectedAsset.metaData.symbol.toUpperCase()}` + : 'Buy Now'; return ( <Button width="100%" @@ -45,7 +51,7 @@ export class BuyButton extends React.Component<BuyButtonProps> { isDisabled={shouldDisableButton} fontColor={ColorOption.white} > - Buy + {buttonText} </Button> ); } |