import { useState } from "react"; import { observer } from "mobx-react"; import { Lock, Sparkle } from "lucide-react"; // editor import { EditorReadOnlyRefApi, EditorRefApi } from "@plane/document-editor"; // ui import { ArchiveIcon } from "@plane/ui"; // components import { GptAssistantPopover } from "@/components/core"; import { PageInfoPopover, PageOptionsDropdown } from "@/components/pages"; // helpers import { renderFormattedDate } from "@/helpers/date-time.helper"; // hooks import { useInstance } from "@/hooks/store"; // store import { IPageStore } from "@/store/pages/page.store"; type Props = { editorRef: React.RefObject; handleDuplicatePage: () => void; page: IPageStore; projectId: string; readOnlyEditorRef: React.RefObject; }; export const PageExtraOptions: React.FC = observer((props) => { const { editorRef, handleDuplicatePage, page, projectId, readOnlyEditorRef } = props; // states const [gptModalOpen, setGptModal] = useState(false); // store hooks const { config } = useInstance(); // derived values const { archived_at, isContentEditable, is_locked } = page; const handleAiAssistance = async (response: string) => { if (!editorRef) return; editorRef.current?.setEditorValueAtCursorPosition(response); }; return (
{is_locked && (
Locked
)} {archived_at && (
Archived at {renderFormattedDate(archived_at)}
)} {isContentEditable && config?.has_openai_configured && ( { setGptModal((prevData) => !prevData); // this is done so that the title do not reset after gpt popover closed // reset(getValues()); }} onResponse={handleAiAssistance} placement="top-end" button={ } className="!min-w-[38rem]" /> )}
); });