diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-10-18 07:41:35 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-10-18 07:41:35 +0800 |
commit | 6cf8d57aee3ed332bd1109f8f39792894147d2dd (patch) | |
tree | 2a12a521fa6bba01f64799ad40acbb3b074f9cff /packages/instant/src/components/instant_heading.tsx | |
parent | 7b43cd14b305e3f01081e7ea7d0385966e4529be (diff) | |
download | dexon-0x-contracts-6cf8d57aee3ed332bd1109f8f39792894147d2dd.tar.gz dexon-0x-contracts-6cf8d57aee3ed332bd1109f8f39792894147d2dd.tar.zst dexon-0x-contracts-6cf8d57aee3ed332bd1109f8f39792894147d2dd.zip |
add concept of quoteState
Diffstat (limited to 'packages/instant/src/components/instant_heading.tsx')
-rw-r--r-- | packages/instant/src/components/instant_heading.tsx | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/packages/instant/src/components/instant_heading.tsx b/packages/instant/src/components/instant_heading.tsx index 492c1b2c0..848056800 100644 --- a/packages/instant/src/components/instant_heading.tsx +++ b/packages/instant/src/components/instant_heading.tsx @@ -4,6 +4,7 @@ import * as React from 'react'; import { SelectedAssetAmountInput } from '../containers/selected_asset_amount_input'; import { ColorOption } from '../style/theme'; +import { AsyncProcessState } from '../types'; import { format } from '../util/format'; import { Container, Flex, Text } from './ui'; @@ -12,20 +13,33 @@ export interface InstantHeadingProps { selectedAssetAmount?: BigNumber; totalEthBaseAmount?: BigNumber; ethUsdPrice?: BigNumber; + quoteState: AsyncProcessState; } const displaytotalEthBaseAmount = ({ selectedAssetAmount, totalEthBaseAmount }: InstantHeadingProps): string => { if (_.isUndefined(selectedAssetAmount)) { return '0 ETH'; } - return format.ethBaseAmount(totalEthBaseAmount, 4, '...loading'); + return format.ethBaseAmount(totalEthBaseAmount, 4, '-'); }; const displayUsdAmount = ({ totalEthBaseAmount, selectedAssetAmount, ethUsdPrice }: InstantHeadingProps): string => { if (_.isUndefined(selectedAssetAmount)) { return '$0.00'; } - return format.ethBaseAmountInUsd(totalEthBaseAmount, ethUsdPrice, 2, '...loading'); + return format.ethBaseAmountInUsd(totalEthBaseAmount, ethUsdPrice, 2, '-'); +}; + +const loadingOrAmount = (quoteState: AsyncProcessState, amount: string): React.ReactNode => { + if (quoteState === AsyncProcessState.PENDING) { + return ( + <Text fontWeight="bold" fontColor={ColorOption.white}> + …loading + </Text> + ); + } else { + return amount; + } }; export const InstantHeading: React.StatelessComponent<InstantHeadingProps> = props => ( @@ -47,11 +61,11 @@ export const InstantHeading: React.StatelessComponent<InstantHeadingProps> = pro <Flex direction="column" justify="space-between"> <Container marginBottom="5px"> <Text fontSize="16px" fontColor={ColorOption.white} fontWeight={500}> - {displaytotalEthBaseAmount(props)} + {loadingOrAmount(props.quoteState, displaytotalEthBaseAmount(props))} </Text> </Container> <Text fontSize="16px" fontColor={ColorOption.white} opacity={0.7}> - {displayUsdAmount(props)} + {loadingOrAmount(props.quoteState, displayUsdAmount(props))} </Text> </Flex> </Flex> |