/* 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 * as CSS from 'csstype' import { StyledWrapper, StyledHeaderText, StyledOverlayTop, StyledOverlayContent, StyledMessage, StyledIcon, StyledIconWrapper, StyledProviderImage, StyledFailWrapper, StyledCloseIcon, StyledFailTitle, StyledFailMsg, StyledOuterWrapper, StyledBackgroundCurve, StyledImageBorder, StyleSubHeaderText, StyledLetter, StyledClose, StyledLogoWrapper, StyledLogoBorder, StyledLogoImage, StyledDomainText, StyledDateText, StyledDate, StyledMonthlyInfo } from './style' import { getLocale } from '../../../helpers' import { CloseCircleOIcon, PaperAirplaneIcon } from '../../../components/icons' export interface Props { id?: string send?: boolean success?: boolean siteImg?: string domain?: string logoBgColor?: CSS.Color logo?: string amount?: string monthlyDate?: string onClose: () => void } export default class DonationOverlay extends React.PureComponent { getFailureContent () { return ( {getLocale('uhOh')} {getLocale('donationFailureMsg')} ) } getOverlayContent = () => { const { success, send, siteImg, logo, domain, logoBgColor, amount, monthlyDate } = this.props return ( { success || send ? { send ? : null } { !send && siteImg ? : null } { !send && !siteImg && !logo && domain ? {(domain && domain.substring(0, 1)) || ''} : null } { !send && !siteImg && logo ? : null } { send ? getLocale('donationSent') : null } { success ? <> {getLocale('thankYou')} { monthlyDate ? getLocale('autoTipText') : getLocale('tipText') } {domain}
{amount} {getLocale('bat')} { monthlyDate ? `, ${getLocale('monthlyText')}` : null }
{ monthlyDate ? <> {getLocale('firstTipDateText')} {monthlyDate} : null }
: null }
: this.getFailureContent() }
) } render () { const { id, send, onClose } = this.props return ( { send ? : null } {this.getOverlayContent()} ) } }