import type { FC, ReactNode } from "react"; import { useRef } from "react"; import { observer } from "mobx-react"; // plane imports import { useTranslation } from "@plane/i18n"; import type { TIssueComment } from "@plane/types"; import { EIssueCommentAccessSpecifier } from "@plane/types"; import { Avatar, Tooltip } from "@plane/ui"; import { calculateTimeAgo, cn, getFileURL, renderFormattedDate, renderFormattedTime } from "@plane/utils"; // hooks import { useMember } from "@/hooks/store/use-member"; type TCommentBlock = { comment: TIssueComment; ends: "top" | "bottom" | undefined; quickActions: ReactNode; children: ReactNode; }; export const CommentBlock: FC = observer((props) => { const { comment, ends, quickActions, children } = props; // refs const commentBlockRef = useRef(null); // store hooks const { getUserDetails } = useMember(); // derived values const userDetails = getUserDetails(comment?.actor); // translation const { t } = useTranslation(); const displayName = comment?.actor_detail?.is_bot ? comment?.actor_detail?.first_name + ` ${t("bot")}` : (userDetails?.display_name ?? comment?.actor_detail?.display_name); const avatarUrl = userDetails?.avatar_url ?? comment?.actor_detail?.avatar_url; if (!comment) return null; return (
{`${displayName}${comment.access === EIssueCommentAccessSpecifier.EXTERNAL ? " (External User)" : ""}`}
commented{" "} {calculateTimeAgo(comment.updated_at)} {comment.edited_at && ` (${t("edited")})`}
{quickActions}
{children}
); });