diff --git a/apps/app/components/core/bulk-delete-issues-modal.tsx b/apps/app/components/core/bulk-delete-issues-modal.tsx index a2d1051ca..ac35d9516 100644 --- a/apps/app/components/core/bulk-delete-issues-modal.tsx +++ b/apps/app/components/core/bulk-delete-issues-modal.tsx @@ -35,10 +35,7 @@ export const BulkDeleteIssuesModal: React.FC = ({ isOpen, setIsOpen }) => const [query, setQuery] = useState(""); const router = useRouter(); - - const { - query: { workspaceSlug, projectId }, - } = router; + const { workspaceSlug, projectId } = router.query; const { data: issues } = useSWR( workspaceSlug && projectId diff --git a/apps/app/components/issues/form.tsx b/apps/app/components/issues/form.tsx index 3194481b6..2b4c4778c 100644 --- a/apps/app/components/issues/form.tsx +++ b/apps/app/components/issues/form.tsx @@ -49,7 +49,7 @@ const defaultValues: Partial = { }; export interface IssueFormProps { - handleFormSubmit: (values: Partial) => void; + handleFormSubmit: (values: Partial) => Promise; initialData?: Partial; issues: IIssue[]; projectId: string; @@ -107,17 +107,18 @@ export const IssueForm: FC = ({ reset({ ...defaultValues, project: projectId, + description: "", + description_html: "

", }); }; useEffect(() => { reset({ ...defaultValues, - ...watch(), - project: projectId, ...initialData, + project: projectId, }); - }, [initialData, reset, watch, projectId]); + }, [initialData, reset, projectId]); return ( <> @@ -238,13 +239,11 @@ export const IssueForm: FC = ({ ( + render={({ field: { value } }) => ( { - setValue("description", jsonValue); - setValue("description_html", htmlValue); - }} + onJSONChange={(jsonValue) => setValue("description", jsonValue)} + onHTMLChange={(htmlValue) => setValue("description_html", htmlValue)} placeholder="Enter Your Text..." /> )} diff --git a/apps/app/components/issues/modal.tsx b/apps/app/components/issues/modal.tsx index c7ff0c2d7..24c15ae52 100644 --- a/apps/app/components/issues/modal.tsx +++ b/apps/app/components/issues/modal.tsx @@ -141,30 +141,20 @@ export const CreateUpdateIssueModal: React.FC = ({ if (!createMore) handleClose(); setToastAlert({ - title: "Success", type: "success", - message: "Issue created successfully", + title: "Success!", + message: "Issue created successfully.", }); if (payload.assignees_list?.some((assignee) => assignee === user?.id)) mutate(USER_ISSUE); if (payload.parent && payload.parent !== "") mutate(SUB_ISSUES(payload.parent)); }) - .catch((err) => { - if (err.detail) { - setToastAlert({ - title: "Join the project.", - type: "error", - message: "Click select to join from projects page to start making changes", - }); - } - Object.keys(err).map((key) => { - const message = err[key]; - if (!message) return; - - setError(key as keyof IIssue, { - message: Array.isArray(message) ? message.join(", ") : message, - }); + .catch(() => { + setToastAlert({ + type: "error", + title: "Error!", + message: "Issue could not be created. Please try again.", }); }); }; @@ -194,14 +184,16 @@ export const CreateUpdateIssueModal: React.FC = ({ if (!createMore) handleClose(); setToastAlert({ - title: "Success", type: "success", - message: "Issue updated successfully", + title: "Success!", + message: "Issue updated successfully.", }); }) - .catch((err) => { - Object.keys(err).map((key) => { - setError(key as keyof IIssue, { message: err[key].join(", ") }); + .catch(() => { + setToastAlert({ + type: "error", + title: "Error!", + message: "Issue could not be updated. Please try again.", }); }); }; @@ -211,8 +203,8 @@ export const CreateUpdateIssueModal: React.FC = ({ const payload: Partial = { ...formData, - description: formData.description ? formData.description : "", - description_html: formData.description_html ? formData.description_html : "

", + description: formData.description ?? "", + description_html: formData.description_html ?? "

", }; if (!data) await createIssue(payload);