import * as React from 'react'; import I18n from 'i18n-js'; import Gravatar from 'react-gravatar'; import NewComment from './NewComment'; import Separator from '../shared/Separator'; import { MutedText } from '../shared/CustomTexts'; import { ReplyFormState } from '../../reducers/replyFormReducer'; import friendlyDate from '../../helpers/datetime'; interface Props { id: number; body: string; isPostUpdate: boolean; userFullName: string; userEmail: string; updatedAt: string; replyForm: ReplyFormState; handleToggleCommentReply(): void; handleCommentReplyBodyChange(e: React.FormEvent): void; handleToggleIsCommentUpdate(commentId: number, currentIsPostUpdate: boolean): void; handleSubmitComment(body: string, parentId: number, isPostUpdate: boolean): void; isLoggedIn: boolean; isPowerUser: boolean; currentUserEmail: string; } const Comment = ({ id, body, isPostUpdate, userFullName, userEmail, updatedAt, replyForm, handleToggleCommentReply, handleCommentReplyBodyChange, handleToggleIsCommentUpdate, handleSubmitComment, isLoggedIn, isPowerUser, currentUserEmail, }: Props) => (
{userFullName} { isPostUpdate ? {I18n.t('post.comments.post_update_badge')} : null }

{body}

{ replyForm.isOpen ? I18n.t('common.buttons.cancel') : I18n.t('post.comments.reply_button') } { isPowerUser ? handleToggleIsCommentUpdate(id, isPostUpdate)} className="commentLink" > { 'Post update: ' + (isPostUpdate ? 'yes' : 'no') } {I18n.t('common.buttons.edit')} {I18n.t('common.buttons.delete')} : null } {friendlyDate(updatedAt)}
{ replyForm.isOpen ? null} handleSubmit={handleSubmitComment} isLoggedIn={isLoggedIn} isPowerUser={isPowerUser} userEmail={currentUserEmail} /> : null }
); export default Comment;