aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/organisms/layout/comments-list.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-05-23 14:07:02 +0200
committerArmand Philippot <git@armandphilippot.com>2022-05-23 16:00:13 +0200
commit34e216546151eaf8a0a3cbb0bc8b65dae4c63bf2 (patch)
treebff34f8a1dc65f0559ddf851433f242edb092824 /src/components/organisms/layout/comments-list.tsx
parent0f8f963ba3eccd7fd94785bf7fb216b6287cec57 (diff)
refactor: reduce the number of data transformation
Diffstat (limited to 'src/components/organisms/layout/comments-list.tsx')
-rw-r--r--src/components/organisms/layout/comments-list.tsx11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/components/organisms/layout/comments-list.tsx b/src/components/organisms/layout/comments-list.tsx
index f04354c..97eccb7 100644
--- a/src/components/organisms/layout/comments-list.tsx
+++ b/src/components/organisms/layout/comments-list.tsx
@@ -1,13 +1,10 @@
import SingleComment, {
type CommentProps,
} from '@components/organisms/layout/comment';
+import { Comment } from '@ts/types/app';
import { FC } from 'react';
import styles from './comments-list.module.scss';
-export type Comment = Omit<CommentProps, 'canReply' | 'saveComment'> & {
- child?: Comment[];
-};
-
export type CommentsListProps = Pick<CommentProps, 'Notice' | 'saveComment'> & {
/**
* An array of comments.
@@ -42,7 +39,7 @@ const CommentsList: FC<CommentsListProps> = ({
): JSX.Element[] => {
const isLastLevel = startLevel === depth;
- return commentsList.map(({ child, ...comment }) => (
+ return commentsList.map(({ replies, ...comment }) => (
<li key={comment.id} className={styles.item}>
<SingleComment
canReply={!isLastLevel}
@@ -50,8 +47,8 @@ const CommentsList: FC<CommentsListProps> = ({
saveComment={saveComment}
{...comment}
/>
- {child && !isLastLevel && (
- <ol className={styles.list}>{getItems(child, startLevel + 1)}</ol>
+ {replies && !isLastLevel && (
+ <ol className={styles.list}>{getItems(replies, startLevel + 1)}</ol>
)}
</li>
));