import React from 'react'; // import classNames from 'classnames'; import { ContactName } from './ContactName'; import { Intl } from '../Intl'; import { Localizer } from '../../types/Util'; import { MessageBody } from './MessageBody'; interface Contact { phoneNumber: string; profileName?: string; name?: string; } interface Props { text?: string; type: 'incoming' | 'outgoing'; source: Contact; target: Contact; i18n: Localizer; status: 'pending' | 'accepted' | 'declined'; onAccept: () => void; onDecline: () => void; } export class FriendRequest extends React.Component { public getStringId() { const { type, status } = this.props; switch (status) { case 'pending': return `${type}FriendRequestPending`; case 'accepted': return `${type}FriendRequestAccepted`; case 'declined': return `${type}FriendRequestDeclined`; default: throw new Error(`Invalid friend request status: ${status}`); } } public renderText() { const { type, text, i18n } = this.props; if (!text) { return null; } return (
); } public renderContents() { const { source, i18n } = this.props; const id = this.getStringId(); return (
, ]} i18n={i18n} /> {this.renderText()}
); } public renderButtons() { const { type, onAccept, onDecline } = this.props; return (
) } public render() { const { type, status} = this.props; const shouldRenderButtons = (status === 'pending' && type === 'incoming'); return (
{this.renderContents()} {shouldRenderButtons && this.renderButtons()}
); } }