import React from "react"; // next import { useRouter } from "next/router"; // react-hook-form import { useForm, Controller } from "react-hook-form"; // hooks import useProjectDetails from "hooks/use-project-details"; // components import { TipTapEditor } from "components/tiptap"; // icons import { Send } from "lucide-react"; // ui import { Icon, SecondaryButton, Tooltip, PrimaryButton } from "components/ui"; // types import type { IIssueComment } from "types"; const defaultValues: Partial = { access: "INTERNAL", comment_html: "", }; type Props = { disabled?: boolean; onSubmit: (data: IIssueComment) => Promise; }; const commentAccess = [ { icon: "lock", key: "INTERNAL", label: "Private", }, { icon: "public", key: "EXTERNAL", label: "Public", }, ]; export const AddComment: React.FC = ({ disabled = false, onSubmit }) => { const editorRef = React.useRef(null); const router = useRouter(); const { workspaceSlug } = router.query; const { projectDetails } = useProjectDetails(); const showAccessSpecifier = projectDetails?.is_deployed; const { control, formState: { isSubmitting }, handleSubmit, reset, } = useForm({ defaultValues }); const handleAddComment = async (formData: IIssueComment) => { if (!formData.comment_html || isSubmitting) return; await onSubmit(formData).then(() => { reset(defaultValues); editorRef.current?.clearEditor(); }); }; return (
{showAccessSpecifier && (
(
{commentAccess.map((access) => ( ))}
)} />
)} (

" : value} customClassName="p-3 min-h-[100px] shadow-sm" debouncedUpdatesEnabled={false} onChange={(comment_json: Object, comment_html: string) => onChange(comment_html)} /> )} />
); };