aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-12-12 06:55:32 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-12-12 06:55:32 +0800
commitee7d6fb3afad313fa699018c727c24db4f2024bd (patch)
tree3cc9a4401b1fe00de897fb354271c5f11d637c9a /packages/instant
parent286474ca767e955b4f7fca985d3864511fa4dfbb (diff)
downloaddexon-sol-tools-ee7d6fb3afad313fa699018c727c24db4f2024bd.tar.gz
dexon-sol-tools-ee7d6fb3afad313fa699018c727c24db4f2024bd.tar.zst
dexon-sol-tools-ee7d6fb3afad313fa699018c727c24db4f2024bd.zip
Show as 0 when selected
Diffstat (limited to 'packages/instant')
-rw-r--r--packages/instant/src/components/order_details.tsx18
-rw-r--r--packages/instant/src/constants.ts1
-rw-r--r--packages/instant/src/util/asset.ts3
3 files changed, 14 insertions, 8 deletions
diff --git a/packages/instant/src/components/order_details.tsx b/packages/instant/src/components/order_details.tsx
index 2fcde5aa4..67090898e 100644
--- a/packages/instant/src/components/order_details.tsx
+++ b/packages/instant/src/components/order_details.tsx
@@ -3,10 +3,10 @@ import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';
import * as React from 'react';
+import { DEFAULT_UNKOWN_ASSET_NAME } from '../constants';
import { ColorOption } from '../style/theme';
import { BaseCurrency } from '../types';
import { buyQuoteUtil } from '../util/buy_quote';
-import { format } from '../util/format';
import { AmountPlaceholder } from './amount_placeholder';
@@ -171,7 +171,7 @@ export interface TokenAmountRowProps {
numTokens?: BigNumber;
}
export class TokenAmountRow extends React.Component<TokenAmountRowProps> {
- public static DEFAULT_TEXT: string = 'Token Price';
+ public static DEFAULT_TEXT: string = 'Token Amount';
public render(): React.ReactNode {
return (
<OrderDetailsRow
@@ -182,11 +182,15 @@ export class TokenAmountRow extends React.Component<TokenAmountRowProps> {
);
}
private _labelText(): string {
- if (this.props.isLoading) {
- return TokenAmountRow.DEFAULT_TEXT;
- }
- const { numTokens, displayPricePerToken, assetName } = this.props;
- if (numTokens) {
+ const { displayPricePerToken, assetName } = this.props;
+
+ // Display as 0 if we have a selected asset
+ const numTokens =
+ assetName && assetName !== DEFAULT_UNKOWN_ASSET_NAME && _.isUndefined(this.props.numTokens)
+ ? 0
+ : this.props.numTokens;
+
+ if (!_.isUndefined(numTokens)) {
let numTokensWithSymbol = numTokens.toString();
if (assetName) {
diff --git a/packages/instant/src/constants.ts b/packages/instant/src/constants.ts
index f83eb4ac7..975dfcbea 100644
--- a/packages/instant/src/constants.ts
+++ b/packages/instant/src/constants.ts
@@ -17,6 +17,7 @@ export const ONE_MINUTE_MS = ONE_SECOND_MS * 60;
export const GIT_SHA = process.env.GIT_SHA;
export const NODE_ENV = process.env.NODE_ENV;
export const NPM_PACKAGE_VERSION = process.env.NPM_PACKAGE_VERSION;
+export const DEFAULT_UNKOWN_ASSET_NAME = '???';
export const ACCOUNT_UPDATE_INTERVAL_TIME_MS = ONE_SECOND_MS * 5;
export const BUY_QUOTE_UPDATE_INTERVAL_TIME_MS = ONE_SECOND_MS * 15;
export const DEFAULT_GAS_PRICE = GWEI_IN_WEI.mul(6);
diff --git a/packages/instant/src/util/asset.ts b/packages/instant/src/util/asset.ts
index 13f84ef74..faaeb7c22 100644
--- a/packages/instant/src/util/asset.ts
+++ b/packages/instant/src/util/asset.ts
@@ -2,6 +2,7 @@ import { AssetBuyerError } from '@0x/asset-buyer';
import { AssetProxyId, ObjectMap } from '@0x/types';
import * as _ from 'lodash';
+import { DEFAULT_UNKOWN_ASSET_NAME } from '../constants';
import { assetDataNetworkMapping } from '../data/asset_data_network_mapping';
import { Asset, AssetMetaData, ERC20Asset, Network, ZeroExInstantError } from '../types';
@@ -71,7 +72,7 @@ export const assetUtils = {
}
return metaData;
},
- bestNameForAsset: (asset?: Asset, defaultName: string = '???'): string => {
+ bestNameForAsset: (asset?: Asset, defaultName: string = DEFAULT_UNKOWN_ASSET_NAME): string => {
if (_.isUndefined(asset)) {
return defaultName;
}