/* 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' // Helpers import { getLocale } from '../../../helpers' // Styled Components import { StyledWrapper, StyledAttentionScore, StyledAttentionScoreTitle, StyledContainer, StyledScoreWrapper, StyledControlsWrapper, StyledDonateText, StyledDonateWrapper, StyledToggleWrapper, StyledSelectWrapper, StyledGrid, StyledColumn, StyleToggleTips, StyledNoticeWrapper, StyledNoticeLink, StyledProfileWrapper, StyledSelect } from './style' // Components import { Toggle } from '../../../components' import { RewardsButton } from '../' import ToggleTips from '../toggleTips/index' import Profile, { Provider } from '../profile/index' export type Token = { tokens: string converted: string } export interface Props { id?: string platform?: Provider publisherImg?: string publisherName?: string isVerified?: boolean attentionScore?: string | null tipsEnabled: boolean includeInAuto: boolean monthlyAmount: string donationAmounts?: Token[] toggleTips?: boolean donationAction: () => void onToggleTips: () => void onAmountChange: (event: React.ChangeEvent) => void onIncludeInAuto: () => void onRefreshPublisher?: () => void refreshingPublisher?: boolean publisherRefreshed?: boolean showUnVerified?: boolean moreLink?: string acEnabled?: boolean } export default class WalletPanel extends React.PureComponent { publisherInfo () { const publisherTitle = this.props.publisherName || '' return ( ) } donationDropDown () { const { donationAmounts } = this.props const monthlyAmount = this.props.monthlyAmount || '5.0' if (!donationAmounts) { return null } return ( {donationAmounts.map((token: Token, index: number) => { const tokenValue = token.tokens.toString() const paddingLength = tokenValue.length < 5 ? tokenValue.length === 4 ? 3 : 4 : 0 const padding = `${String.fromCharCode(160)}`.repeat(paddingLength) return ( ) })} ) } donationControls () { const { donationAmounts, acEnabled } = this.props if (!donationAmounts && !acEnabled) { return null } return ( { acEnabled ? {getLocale('includeInAuto')} : null } { donationAmounts ? {getLocale('donateMonthly')} {this.donationDropDown()} : null } ) } render () { const { id, platform, onToggleTips, attentionScore, tipsEnabled, donationAction, toggleTips, showUnVerified, isVerified, moreLink, acEnabled } = this.props const donationControls = this.donationControls() return ( {this.publisherInfo()} { !isVerified && showUnVerified ? {getLocale('unVerifiedText')}{' '} {' '} {getLocale('unVerifiedTextMore')} : null } { acEnabled ? {getLocale('rewardsContributeAttentionScore')} {attentionScore}% : null } { donationControls ? {donationControls} : null } ) } }