/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' import { StyledType, StyledDate, StyledRemove, StyledRemoveIcon, StyledToggle, StyledToggleWrap, StyledLink } from './style' import Table, { Cell, Row } from '../../../components/dataTables/table/index' import Profile, { Provider } from '../profile/index' import Tokens from '../tokens/index' import { getLocale } from '../../../helpers' import { TrashIcon } from '../../../components/icons' interface ProfileCell { verified: boolean name: string src: string provider?: Provider } type DonationType = 'donation' | 'tip' | 'recurring' export interface DetailRow { profile: ProfileCell contribute: { tokens: string converted: string } url: string type: DonationType text?: string | React.ReactNode onRemove?: () => void } export interface Props { id?: string children?: React.ReactNode rows?: DetailRow[] numItems?: number allItems?: boolean onShowAll?: () => void headerColor?: boolean } export default class TableDonation extends React.PureComponent { getTypeContent (row: DetailRow): Cell { switch (row.type) { case 'recurring': return { content: ( <> {getLocale('recurring')} {getLocale('remove')} ) } case 'donation': return { content: ( <> {getLocale('oneTime')} {row.text} ) } case 'tip': return { content: ( <> {getLocale('tipOnLike')} {row.text} ) } } } getRows (rows?: DetailRow[]): Row[] | undefined { if (!rows) { return } return rows.map((row: DetailRow): Row => { return { content: [ { content: ( ) }, this.getTypeContent(row), { content: ( ), customStyle: { 'text-align': 'right', 'padding': '0 7px 0 10px', 'max-width': '80px' } } ] } }) } get headers (): Cell[] { let customStyle = {} if (this.props.headerColor) { customStyle = { border: 'none', 'border-bottom': `1px solid #696FDC`, padding: '0', color: '#696FDC' } } return [ { content: getLocale('site'), customStyle }, { content: getLocale('type'), customStyle }, { content: getLocale('tokens'), customStyle: Object.assign({ 'text-align': 'right', 'padding-right': '7px' }, customStyle) } ] } render () { const { id, children, rows, allItems, onShowAll } = this.props const numItems = this.props.numItems || 0 return (
{ !allItems && numItems > 0 ? {getLocale('seeAllItems', { numItems })} : null } ) } }