import * as _ from 'lodash'; import * as React from 'react'; import { ColorOption } from '../style/theme'; import { Account, AccountState, Network, StandardSlidingPanelContent } from '../types'; import { MetaMaskLogo } from './meta_mask_logo'; import { PaymentMethodDropdown } from './payment_method_dropdown'; import { Circle } from './ui/circle'; import { Container } from './ui/container'; import { Flex } from './ui/flex'; import { Text } from './ui/text'; export interface PaymentMethodProps { account: Account; network: Network; openStandardSlidingPanel: (content: StandardSlidingPanelContent) => void; } export class PaymentMethod extends React.Component { public render(): React.ReactNode { return ( {this._renderTitleText()} {this._renderTitleLabel()} {this._renderMainContent()} ); } private readonly _renderTitleText = (): string => { const { account } = this.props; switch (account.state) { case AccountState.Loading: return 'loading...'; case AccountState.Error: case AccountState.Locked: case AccountState.None: return 'connect your wallet'; case AccountState.Ready: return 'payment method'; default: return 'payment method'; } }; private readonly _renderTitleLabel = (): React.ReactNode => { const { account } = this.props; if (account.state === AccountState.Ready) { return ( MetaMask ); } return null; }; private readonly _renderMainContent = (): React.ReactNode => { const { account, network } = this.props; switch (account.state) { case AccountState.Loading: return 'loading...'; case AccountState.Locked: return Unlock MetaMask; case AccountState.None: return Install MetaMask; case AccountState.Ready: return ( ); default: return 'payment method'; } }; private readonly _openInstallWalletPanel = () => { this.props.openStandardSlidingPanel(StandardSlidingPanelContent.InstallWallet); }; } interface WalletPromptProps { onClick?: () => void; } const WalletPrompt: React.StatelessComponent = ({ onClick, children }) => ( {children} );