import React from 'react'; import { translateRaw } from 'translations'; import { TokenValue } from 'libs/units'; import removeIcon from 'assets/images/icon-remove.svg'; import { UnitDisplay } from 'components/ui'; import './TokenRow.scss'; type ToggleTrackedFn = (symbol: string) => void; interface Props { balance: TokenValue; symbol: string; custom?: boolean; decimal: number; tracked: boolean; toggleTracked: ToggleTrackedFn | false; onRemove(symbol: string): void; } interface State { showLongBalance: boolean; } export default class TokenRow extends React.PureComponent { public state = { showLongBalance: false }; public render() { const { balance, symbol, custom, decimal, tracked } = this.props; const { showLongBalance } = this.state; return ( {/* Only allow to toggle tracking on non custom tokens because the user can just remove the custom token instead */} {this.props.toggleTracked && ( )} {symbol} {!!custom && ( {translateRaw('REMOVE')} )} ); } public toggleShowLongBalance = (e: React.FormEvent) => { e.preventDefault(); this.setState(state => { return { showLongBalance: !state.showLongBalance }; }); }; private onRemove = () => { this.props.onRemove(this.props.symbol); }; private handleToggleTracked = () => { if (this.props.toggleTracked) { this.props.toggleTracked(this.props.symbol); } }; }