import * as React from 'react'; 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 ? Post update : null }

{body}

{ replyForm.isOpen ? 'Cancel' : 'Reply' } { isPowerUser ? handleToggleIsCommentUpdate(id, isPostUpdate)} className="commentLink" > { 'Post update: ' + (isPostUpdate ? 'yes' : 'no') } Edit Delete : null } {friendlyDate(updatedAt)}
{ replyForm.isOpen ? null} handleSubmit={handleSubmitComment} isLoggedIn={isLoggedIn} isPowerUser={isPowerUser} userEmail={currentUserEmail} /> : null }
); export default Comment;