import { BuyQuoteInfo } from '@0x/asset-buyer'; 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 { AmountPlaceholder } from './amount_placeholder'; import { Container } from './ui/container'; import { Flex } from './ui/flex'; import { Text, TextProps } from './ui/text'; interface BaseCurrenySwitchProps { currencyName: string; onClick: () => void; isSelected: boolean; } const BaseCurrencySelector: React.StatelessComponent = props => { const textStyle: TextProps = { onClick: props.onClick, fontSize: '12px' }; if (props.isSelected) { textStyle.fontColor = ColorOption.primaryColor; textStyle.fontWeight = 700; } return {props.currencyName}; }; export interface OrderDetailsProps { buyQuoteInfo?: BuyQuoteInfo; selectedAssetUnitAmount?: BigNumber; ethUsdPrice?: BigNumber; isLoading: boolean; assetName?: string; baseCurrency: BaseCurrency; onBaseCurrencySwitchEth: () => void; onBaseCurrencySwitchUsd: () => void; } export class OrderDetails extends React.Component { public render(): React.ReactNode { const { buyQuoteInfo, ethUsdPrice, selectedAssetUnitAmount } = this.props; const weiAmounts = buyQuoteUtil.getWeiAmounts(selectedAssetUnitAmount, buyQuoteInfo); const displayAmounts = this.props.baseCurrency === BaseCurrency.USD ? buyQuoteUtil.displayAmountsUsd(weiAmounts, ethUsdPrice) : buyQuoteUtil.displayAmountsEth(weiAmounts, ethUsdPrice); return ( Order Details / ); } } export interface EthAmountRowProps { rowLabel: string; ethAmount?: BigNumber; isEthAmountInBaseUnits?: boolean; ethUsdPrice?: BigNumber; shouldEmphasize?: boolean; isLoading: boolean; } export interface OrderDetailsRowProps { labelText: string; isLabelBold?: boolean; isLoading: boolean; value?: React.ReactNode; } export class OrderDetailsRow extends React.Component { public render(): React.ReactNode { const { labelText, value, isLabelBold, isLoading } = this.props; return ( {labelText} {value || ( )} ); } } export interface TotalCostRowProps { displayPrimaryTotalCost?: React.ReactNode; displaySecondaryTotalCost?: React.ReactNode; isLoading: boolean; } export class TotalCostRow extends React.Component { public render(): React.ReactNode { let value: React.ReactNode; if (this.props.displayPrimaryTotalCost) { const secondaryText = this.props.displaySecondaryTotalCost && ( ({this.props.displaySecondaryTotalCost}) ); value = ( {secondaryText} {this.props.displayPrimaryTotalCost} ); } return ( ); } } export interface TokenAmountRowProps { assetName?: string; displayPricePerToken?: React.ReactNode; displayTotalPrice?: React.ReactNode; isLoading: boolean; numTokens?: BigNumber; } export class TokenAmountRow extends React.Component { public static DEFAULT_TEXT: string = 'Token Amount'; public render(): React.ReactNode { return ( ); } private _labelText(): string { 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) { numTokensWithSymbol += ` ${assetName}`; } if (displayPricePerToken) { numTokensWithSymbol += ` @ ${displayPricePerToken}`; } return numTokensWithSymbol; } return TokenAmountRow.DEFAULT_TEXT; } }