Files
astuto/app/javascript/components/Comments/Comment.tsx

54 lines
1.1 KiB
TypeScript
Raw Normal View History

2019-09-17 17:04:19 +02:00
import * as React from 'react';
import { FormEvent } from 'react';
2019-09-17 17:04:19 +02:00
import { MutedText } from '../shared/CustomTexts';
import { CommentRepliesState } from '../../reducers/commentRepliesReducer';
2019-09-17 17:04:19 +02:00
interface Props {
id: number;
body: string;
parentId: number;
userFullName: string;
updatedAt: string;
level: number;
reply: CommentRepliesState;
handleToggleCommentReply(): void;
handleCommentReplyBodyChange(e: FormEvent): void;
2019-09-17 17:04:19 +02:00
}
const Comment = ({
id,
body,
parentId,
userFullName,
updatedAt,
level,
reply,
handleToggleCommentReply,
handleCommentReplyBodyChange,
2019-09-17 17:04:19 +02:00
}: Props) => (
<div className="comment">
<div className="commentHeader">
<span className="commentAuthor">{userFullName}</span>
</div>
<p className="commentBody">{body}</p>
<div className="commentFooter">
<a onClick={handleToggleCommentReply}>Reply</a>
2019-09-17 17:04:19 +02:00
<MutedText>{updatedAt}</MutedText>
</div>
{
reply.isOpen ?
<textarea
value={reply.body}
onChange={handleCommentReplyBodyChange}
/>
:
null
}
2019-09-17 17:04:19 +02:00
</div>
);
export default Comment;