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