import { Divider, Paper, ScrollArea } from '@mantine/core'; import CommentEditor from '@/features/comment/components/comment-editor'; import CommentActions from '@/features/comment/components/comment-actions'; import React, { useState } from 'react'; import CommentListItem from '@/features/comment/components/comment-list-item'; import { IComment } from '@/features/comment/types/comment.types'; import useComment from '@/features/comment/hooks/use-comment'; import { useAtom } from 'jotai'; import { commentsAtom } from '@/features/comment/atoms/comment-atom'; import { useParams } from 'react-router-dom'; import { useFocusWithin } from '@mantine/hooks'; function CommentList({ comments }: IComment[]) { const { createCommentMutation } = useComment(); const { isLoading } = createCommentMutation; const { pageId } = useParams(); const [, setCommentsAtom] = useAtom(commentsAtom(pageId)); const getChildComments = (parentId) => { return comments.filter(comment => comment.parentCommentId === parentId); }; const renderChildComments = (parentId) => { const children = getChildComments(parentId); return (