${response}
`); editorRef.current?.setEditorValue(`${watch("description_html")}`); }; const handleAutoGenerateDescription = async () => { if (!workspaceSlug || !projectId) return; setIAmFeelingLucky(true); aiService .createGptTask( workspaceSlug as string, projectId as string, { prompt: issueName, task: "Generate a proper description for this issue.", }, user ) .then((res) => { if (res.response === "") setToastAlert({ type: "error", title: "Error!", message: "Issue title isn't informative enough to generate the description. Please try with a different title.", }); else handleAiAssistance(res.response_html); }) .catch((err) => { const error = err?.data?.error; if (err.status === 429) setToastAlert({ type: "error", title: "Error!", message: error || "You have reached the maximum number of requests of 50 requests per month per user.", }); else setToastAlert({ type: "error", title: "Error!", message: error || "Some error occurred. Please try again.", }); }) .finally(() => setIAmFeelingLucky(false)); }; useEffect(() => { setFocus("name"); reset({ ...defaultValues, ...initialData, }); }, [setFocus, initialData, reset]); // update projectId in form when projectId changes useEffect(() => { reset({ ...getValues(), project: projectId, }); }, [getValues, projectId, reset]); return ( <> {projectId && ( <>