import { BuyQuoteInfo } from '@0x/asset-buyer'; import { BigNumber } from '@0x/utils'; import * as _ from 'lodash'; import * as React from 'react'; import { oc } from 'ts-optchain'; import { ColorOption } from '../style/theme'; import { format } from '../util/format'; import { Container, Flex, Text } from './ui'; export interface OrderDetailsProps { buyQuoteInfo?: BuyQuoteInfo; ethUsdPrice?: BigNumber; } export class OrderDetails extends React.Component { public render(): React.ReactNode { const { buyQuoteInfo, ethUsdPrice } = this.props; const buyQuoteAccessor = oc(buyQuoteInfo); const ethAssetPrice = buyQuoteAccessor.ethPerAssetPrice(); const ethTokenFee = buyQuoteAccessor.feeEthAmount(); const totalEthAmount = buyQuoteAccessor.totalEthAmount(); return ( Order Details ); } } export interface EthAmountRowProps { rowLabel: string; ethAmount?: BigNumber; isEthAmountInBaseUnits?: boolean; ethUsdPrice?: BigNumber; shouldEmphasize?: boolean; } export const EthAmountRow: React.StatelessComponent = ({ rowLabel, ethAmount, isEthAmountInBaseUnits, ethUsdPrice, shouldEmphasize, }) => { const fontWeight = shouldEmphasize ? 700 : 400; const usdFormatter = isEthAmountInBaseUnits ? format.ethBaseAmountInUsd : format.ethUnitAmountInUsd; const ethFormatter = isEthAmountInBaseUnits ? format.ethBaseAmount : format.ethUnitAmount; const usdPriceSection = _.isUndefined(ethUsdPrice) ? null : ( ({usdFormatter(ethAmount, ethUsdPrice)}) ); return ( {rowLabel} {usdPriceSection} {ethFormatter(ethAmount)} ); }; EthAmountRow.defaultProps = { shouldEmphasize: false, isEthAmountInBaseUnits: true, }; EthAmountRow.displayName = 'EthAmountRow';