aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-12-13 01:51:15 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-12-13 01:51:15 +0800
commitfb99b5ce9d3639e1584214828216879f99dfa020 (patch)
tree2216f9467a2c7fbd5555387f64e3a5e3dd1ceae3 /packages/instant
parentaa8dfa88e113ca7a98887ed77dc8eb3ad39e5f41 (diff)
downloaddexon-0x-contracts-fb99b5ce9d3639e1584214828216879f99dfa020.tar.gz
dexon-0x-contracts-fb99b5ce9d3639e1584214828216879f99dfa020.tar.zst
dexon-0x-contracts-fb99b5ce9d3639e1584214828216879f99dfa020.zip
Show error when fetching usd prices
Diffstat (limited to 'packages/instant')
-rw-r--r--packages/instant/src/components/order_details.tsx36
1 files changed, 32 insertions, 4 deletions
diff --git a/packages/instant/src/components/order_details.tsx b/packages/instant/src/components/order_details.tsx
index 537b9ee4e..ea975a5f7 100644
--- a/packages/instant/src/components/order_details.tsx
+++ b/packages/instant/src/components/order_details.tsx
@@ -27,12 +27,19 @@ export interface OrderDetailsProps {
}
export class OrderDetails extends React.Component<OrderDetailsProps> {
public render(): React.ReactNode {
- const { buyQuoteInfo } = this.props;
-
+ const showUsdError = this.props.baseCurrency === BaseCurrency.USD && this._hadErrorFetchingUsdPrice();
return (
<Container width="100%" flexGrow={1} padding="20px 20px 0px 20px">
<Container marginBottom="10px">{this._renderHeader()}</Container>
+ {showUsdError ? this._renderErrorFetchingUsdPrice() : this._renderRows()}
+ </Container>
+ );
+ }
+ private _renderRows(): React.ReactNode {
+ const { buyQuoteInfo } = this.props;
+ return (
+ <React.Fragment>
<OrderDetailsRow
labelText={this._assetAmountLabel()}
primaryValue={this._displayAmountOrPlaceholder(buyQuoteInfo && buyQuoteInfo.assetEthAmount)}
@@ -48,10 +55,30 @@ export class OrderDetails extends React.Component<OrderDetailsProps> {
isPrimaryValueBold={true}
secondaryValue={this._totalCostSecondaryValue()}
/>
- </Container>
+ </React.Fragment>
);
}
+ private _renderErrorFetchingUsdPrice(): React.ReactNode {
+ return (
+ <Text>
+ There was an error fetching the USD price.
+ <Text
+ onClick={this.props.onBaseCurrencySwitchEth}
+ fontWeight={700}
+ fontColor={ColorOption.primaryColor}
+ >
+ Click here
+ </Text>
+ {' to view ETH prices'}
+ </Text>
+ );
+ }
+
+ private _hadErrorFetchingUsdPrice(): boolean {
+ return this.props.ethUsdPrice === BIG_NUMBER_ZERO;
+ }
+
private _totalCostSecondaryValue(): React.ReactNode {
const secondaryCurrency = this.props.baseCurrency === BaseCurrency.USD ? BaseCurrency.ETH : BaseCurrency.USD;
@@ -92,7 +119,8 @@ export class OrderDetails extends React.Component<OrderDetailsProps> {
}
private _assetAmountLabel(): string {
- const { assetName, baseCurrency } = this.props;
+ const { assetName, baseCurrency, ethUsdPrice } = this.props;
+
const numTokens = this.props.selectedAssetUnitAmount;
// Display as 0 if we have a selected asset