diff --git a/apps/app/components/core/gpt-assistant-modal.tsx b/apps/app/components/core/gpt-assistant-modal.tsx index 37104e30f..653ea3e01 100644 --- a/apps/app/components/core/gpt-assistant-modal.tsx +++ b/apps/app/components/core/gpt-assistant-modal.tsx @@ -121,7 +121,7 @@ export const GptAssistantModal: React.FC = ({ return (
@@ -138,7 +138,7 @@ export const GptAssistantModal: React.FC = ({
)} {response !== "" && ( -
+
Response: ${response}

`} diff --git a/apps/app/components/pages/create-update-block-inline.tsx b/apps/app/components/pages/create-update-block-inline.tsx index 4b8fbcc99..832aa03df 100644 --- a/apps/app/components/pages/create-update-block-inline.tsx +++ b/apps/app/components/pages/create-update-block-inline.tsx @@ -15,8 +15,10 @@ import issuesService from "services/issues.service"; import aiService from "services/ai.service"; // hooks import useToast from "hooks/use-toast"; +// components +import { GptAssistantModal } from "components/core"; // ui -import { Input, Loader, PrimaryButton, SecondaryButton, TextArea } from "components/ui"; +import { Input, Loader, PrimaryButton, SecondaryButton } from "components/ui"; // types import { IPageBlock } from "types"; // fetch-keys @@ -25,9 +27,9 @@ import { PAGE_BLOCKS_LIST } from "constants/fetch-keys"; type Props = { handleClose: () => void; data?: IPageBlock; + handleAiAssistance?: (response: string) => void; setIsSyncing?: React.Dispatch>; focus?: keyof IPageBlock; - setGptAssistantModal: () => void; }; const defaultValues = { @@ -48,11 +50,12 @@ const RemirrorRichTextEditor = dynamic(() => import("components/rich-text-editor export const CreateUpdateBlockInline: React.FC = ({ handleClose, data, + handleAiAssistance, setIsSyncing, focus, - setGptAssistantModal, }) => { const [iAmFeelingLucky, setIAmFeelingLucky] = useState(false); + const [gptAssistantModal, setGptAssistantModal] = useState(false); const router = useRouter(); const { workspaceSlug, projectId, pageId } = router.query; @@ -230,87 +233,101 @@ export const CreateUpdateBlockInline: React.FC = ({ }, [createPageBlock, updatePageBlock, data, handleSubmit]); return ( -
-
-
- -
-
- ( - setValue("description", jsonValue)} - onHTMLChange={(htmlValue) => setValue("description_html", htmlValue)} - placeholder="Write something..." - customClassName="text-sm" - noBorder - borderOnFocus={false} - /> - )} - /> -
- - {data && ( + /> +
+ + - )} +
-
-
- Cancel - - {data - ? isSubmitting - ? "Updating..." - : "Update block" - : isSubmitting - ? "Adding..." - : "Add block"} - -
-
+
+ Cancel + + {data + ? isSubmitting + ? "Updating..." + : "Update block" + : isSubmitting + ? "Adding..." + : "Add block"} + +
+ + setGptAssistantModal(false)} + inset="top-8 left-0" + content={watch("description_html")} + htmlContent={watch("description_html")} + onResponse={(response) => { + if (data && handleAiAssistance) handleAiAssistance(response); + else { + setValue("description", {}); + setValue("description_html", `${watch("description_html")}

${response}

`); + } + }} + projectId={projectId?.toString() ?? ""} + /> +
); }; diff --git a/apps/app/components/pages/single-page-block.tsx b/apps/app/components/pages/single-page-block.tsx index 34b7f6583..ff3811f66 100644 --- a/apps/app/components/pages/single-page-block.tsx +++ b/apps/app/components/pages/single-page-block.tsx @@ -2,12 +2,11 @@ import { useEffect, useState, useRef } from "react"; import { useRouter } from "next/router"; import Link from "next/link"; -import dynamic from "next/dynamic"; import { mutate } from "swr"; // react-hook-form -import { Controller, useForm } from "react-hook-form"; +import { useForm } from "react-hook-form"; // react-beautiful-dnd import { Draggable } from "react-beautiful-dnd"; // services @@ -21,7 +20,7 @@ import useOutsideClickDetector from "hooks/use-outside-click-detector"; import { GptAssistantModal } from "components/core"; import { CreateUpdateBlockInline } from "components/pages"; // ui -import { CustomMenu, Loader } from "components/ui"; +import { CustomMenu } from "components/ui"; // icons import { LayerDiagonalIcon } from "components/icons"; import { ArrowPathIcon, LinkIcon } from "@heroicons/react/20/solid"; @@ -46,15 +45,6 @@ type Props = { index: number; }; -const RemirrorRichTextEditor = dynamic(() => import("components/rich-text-editor"), { - ssr: false, - loading: () => ( - - - - ), -}); - export const SinglePageBlock: React.FC = ({ block, projectDetails, index }) => { const [isSyncing, setIsSyncing] = useState(false); const [createBlockForm, setCreateBlockForm] = useState(false); @@ -291,7 +281,7 @@ export const SinglePageBlock: React.FC = ({ block, projectDetails, index {...provided.dragHandleProps} > setGptAssistantModal((prev) => !prev)} + handleAiAssistance={handleAiAssistance} handleClose={() => setCreateBlockForm(false)} data={block} setIsSyncing={setIsSyncing} diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/pages/[pageId].tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/pages/[pageId].tsx index dbdd3c57f..9d2382d21 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/pages/[pageId].tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/pages/[pageId].tsx @@ -543,7 +543,6 @@ const SinglePage: NextPage = () => { setCreateBlockForm(false)} focus="name" - setGptAssistantModal={() => {}} />
)}