"use client"; import React, { FC, useMemo } from "react"; import { observer } from "mobx-react"; import { useParams } from "next/navigation"; // plane imports import smoothScrollIntoView from "smooth-scroll-into-view-if-needed"; import { E_SORT_ORDER } from "@plane/constants"; import { TCommentsOperations, TIssueComment } from "@plane/types"; // local components import { CommentCard } from "./comment-card"; import { CommentCreate } from "./comment-create"; type TCommentsWrapper = { projectId?: string; entityId: string; isEditingAllowed?: boolean; activityOperations: TCommentsOperations; comments: TIssueComment[] | string[]; sortOrder?: E_SORT_ORDER; getCommentById?: (activityId: string) => TIssueComment | undefined; }; export const CommentsWrapper: FC = observer((props) => { const { entityId, activityOperations, comments, getCommentById, isEditingAllowed = true, projectId } = props; // router const { workspaceSlug: routerWorkspaceSlug } = useParams(); const workspaceSlug = routerWorkspaceSlug?.toString(); const renderCommentCreate = useMemo( () => isEditingAllowed && ( ), [isEditingAllowed, workspaceSlug, entityId, activityOperations, projectId] ); return (
{renderCommentCreate}
{comments?.map((data, index) => { let comment; if (typeof data === "string") { comment = getCommentById?.(data); } else { comment = data; } if (!comment) return null; return ( ); })}
); });