import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';
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';
export interface InstantHeadingProps {
selectedAssetAmount?: BigNumber;
totalEthBaseAmount?: BigNumber;
ethUsdPrice?: BigNumber;
quoteState: AsyncProcessState;
}
const Placeholder = () => (
—
);
const displaytotalEthBaseAmount = ({
selectedAssetAmount,
totalEthBaseAmount,
}: InstantHeadingProps): React.ReactNode => {
if (_.isUndefined(selectedAssetAmount)) {
return '0 ETH';
}
return format.ethBaseAmount(totalEthBaseAmount, 4, );
};
const displayUsdAmount = ({
totalEthBaseAmount,
selectedAssetAmount,
ethUsdPrice,
}: InstantHeadingProps): React.ReactNode => {
if (_.isUndefined(selectedAssetAmount)) {
return '$0.00';
}
return format.ethBaseAmountInUsd(totalEthBaseAmount, ethUsdPrice, 2, );
};
const loadingOrAmount = (quoteState: AsyncProcessState, amount: React.ReactNode): React.ReactNode => {
if (quoteState === AsyncProcessState.PENDING) {
return (
…loading
);
} else {
return amount;
}
};
export const InstantHeading: React.StatelessComponent = props => (
I want to buy
{loadingOrAmount(props.quoteState, displaytotalEthBaseAmount(props))}
{loadingOrAmount(props.quoteState, displayUsdAmount(props))}
);