import React, { useState } from "react"; import { observer } from "mobx-react-lite"; import { Controller, useForm } from "react-hook-form"; import { Menu, Transition } from "@headlessui/react"; import { Check, MessageSquare, MoreVertical, X } from "lucide-react"; // mobx store import { useMobxStore } from "lib/mobx/store-provider"; // components import { LiteReadOnlyEditorWithRef, LiteTextEditorWithRef } from "@plane/lite-text-editor"; import { CommentReactions } from "components/issues/peek-overview"; // helpers import { timeAgo } from "helpers/date-time.helper"; // types import { Comment } from "types/issue"; // services import fileService from "services/file.service"; import useEditorSuggestions from "hooks/use-editor-suggestions"; type Props = { workspaceSlug: string; comment: Comment; }; export const CommentCard: React.FC = observer((props) => { const { comment, workspaceSlug } = props; // store const { user: userStore, issueDetails: issueDetailStore } = useMobxStore(); // states const [isEditing, setIsEditing] = useState(false); const mentionsConfig = useEditorSuggestions(); const editorRef = React.useRef(null); const showEditorRef = React.useRef(null); const { control, formState: { isSubmitting }, handleSubmit, } = useForm({ defaultValues: { comment_html: comment.comment_html }, }); const handleDelete = () => { if (!workspaceSlug || !issueDetailStore.peekId) return; issueDetailStore.deleteIssueComment(workspaceSlug, comment.project, issueDetailStore.peekId, comment.id); }; const handleCommentUpdate = async (formData: Comment) => { if (!workspaceSlug || !issueDetailStore.peekId) return; issueDetailStore.updateIssueComment(workspaceSlug, comment.project, issueDetailStore.peekId, comment.id, formData); setIsEditing(false); editorRef.current?.setEditorValue(formData.comment_html); showEditorRef.current?.setEditorValue(formData.comment_html); }; return (
{comment.actor_detail.avatar && comment.actor_detail.avatar !== "" ? ( // eslint-disable-next-line @next/next/no-img-element { ) : (
{comment.actor_detail.is_bot ? comment?.actor_detail?.first_name?.charAt(0) : comment?.actor_detail?.display_name?.charAt(0)}
)}
{comment.actor_detail.is_bot ? comment.actor_detail.first_name + " Bot" : comment.actor_detail.display_name}

<>commented {timeAgo(comment.created_at)}

( { onChange(comment_html); }} /> )} />
{userStore?.currentUser?.id === comment?.actor_detail?.id && ( {}} className="relative grid cursor-pointer place-items-center rounded p-1 text-custom-text-200 outline-none hover:bg-custom-background-80 hover:text-custom-text-100" > {({ active }) => (
)}
{({ active }) => (
)}
)}
); });