+
+
{author.profile.name}
+
{toCommentDate(dateCreate)}
+
+
{ isDeleted ? t('comments.deleted-comment') : text}
+
+ {!userId && openCommentId === _id && (
+
+ )}
+ {(!!children?.length || isFormShow) && (
+
+ {isFormShow && (
+
+
+
+ )}
+
+ )}
+
+ );
+}
+
+Comment.propTypes = {
+ comment: PropTypes.shape({
+ children: PropTypes.array,
+ _id: PropTypes.string.isRequired,
+ parent: PropTypes.shape({
+ _id: PropTypes.string,
+ _type: PropTypes.oneOf(['article', 'comment']),
+ }),
+ text: PropTypes.string.isRequired,
+ dateCreate: PropTypes.string.isRequired,
+ isDeleted: PropTypes.bool,
+ author: PropTypes.shape({
+ profile: PropTypes.shape({
+ name: PropTypes.string.isRequired,
+ }).isRequired,
+ }).isRequired,
+ }),
+ onCancel: PropTypes.func,
+ onAdd: PropTypes.func,
+ onOpen: PropTypes.func,
+ userId: PropTypes.string,
+ t: PropTypes.func,
+ level: PropTypes.number,
+};
+
+export default memo(Comment);
diff --git a/src/components/comment/style.css b/src/components/comment/style.css
new file mode 100644
index 000000000..24087c29d
--- /dev/null
+++ b/src/components/comment/style.css
@@ -0,0 +1,38 @@
+.Comment-user-date {
+ display: flex;
+ gap: 10px;
+ font-size: 12px;
+}
+
+.Comment-user {
+ font-weight: bold;
+}
+
+.Comment-user_current {
+ color: #666666;
+}
+
+.Comment-date {
+ color: #666666;
+}
+
+.Comment-text {
+ font-size: 14px;
+ margin: 10px 0;
+ padding-right: 20px;
+ overflow-wrap: break-word;
+}
+
+.Comment-answer-btn {
+ color: #0087e9;
+ border: none;
+ background-color: transparent;
+ cursor: pointer;
+ margin-bottom: 26px;
+ padding: 0;
+ font-size: 12px;
+}
+
+.Comment-answer-btn:hover {
+ text-decoration: underline;
+}
diff --git a/src/components/comments-section/index.js b/src/components/comments-section/index.js
new file mode 100644
index 000000000..5eb7b99fd
--- /dev/null
+++ b/src/components/comments-section/index.js
@@ -0,0 +1,63 @@
+import { memo, useMemo, useState } from 'react';
+import PropTypes from 'prop-types';
+import { cn as bem } from '@bem-react/classname';
+import CommentList from '../comment-list';
+import CommentForm from '../comment-form';
+import CommentNoAuth from '../comment-no-auth';
+import listToTree from '../../utils/list-to-tree';
+import './style.css';
+
+
+function CommentsSection({comments, count, t = text => text, articleId, onAdd, userId}) {
+ const cn = bem('CommentsSection');
+ const [openCommentId, setOpenCommentId] = useState(null);
+
+ const commentsTree = useMemo(() => listToTree(comments)[0]?.children || [], [comments]);
+
+ const callbacks = {
+ onCancel: () => setOpenCommentId(null),
+ onAddComment: (text, onSuccess) => onAdd({parent: {_type: 'article', _id: articleId}, text}, onSuccess)
+ }
+ return (
+