import { FC, ReactNode, useRef } from "react"; import { observer } from "mobx-react"; // plane imports import { useTranslation } from "@plane/i18n"; import { TIssueComment } 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(); if (!comment || !userDetails) return null; return (
{comment?.actor_detail?.is_bot ? comment?.actor_detail?.first_name + ` ${t("bot")}` : comment?.actor_detail?.display_name || userDetails.display_name}
commented{" "} {calculateTimeAgo(comment.updated_at)} {comment.edited_at && ` (${t("edited")})`}
{quickActions}
{children}
); });