Skip to content

Commit

Permalink
fix: remirror image not updating (#294)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaryan610 authored Feb 17, 2023
1 parent 1665863 commit 4b06839
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 37 deletions.
5 changes: 1 addition & 4 deletions apps/app/components/core/bulk-delete-issues-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ export const BulkDeleteIssuesModal: React.FC<Props> = ({ 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
Expand Down
17 changes: 8 additions & 9 deletions apps/app/components/issues/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const defaultValues: Partial<IIssue> = {
};

export interface IssueFormProps {
handleFormSubmit: (values: Partial<IIssue>) => void;
handleFormSubmit: (values: Partial<IIssue>) => Promise<void>;
initialData?: Partial<IIssue>;
issues: IIssue[];
projectId: string;
Expand Down Expand Up @@ -107,17 +107,18 @@ export const IssueForm: FC<IssueFormProps> = ({
reset({
...defaultValues,
project: projectId,
description: "",
description_html: "<p></p>",
});
};

useEffect(() => {
reset({
...defaultValues,
...watch(),
project: projectId,
...initialData,
project: projectId,
});
}, [initialData, reset, watch, projectId]);
}, [initialData, reset, projectId]);

return (
<>
Expand Down Expand Up @@ -238,13 +239,11 @@ export const IssueForm: FC<IssueFormProps> = ({
<Controller
name="description"
control={control}
render={({ field: { value, onChange } }) => (
render={({ field: { value } }) => (
<RemirrorRichTextEditor
value={value}
onBlur={(jsonValue, htmlValue) => {
setValue("description", jsonValue);
setValue("description_html", htmlValue);
}}
onJSONChange={(jsonValue) => setValue("description", jsonValue)}
onHTMLChange={(htmlValue) => setValue("description_html", htmlValue)}
placeholder="Enter Your Text..."
/>
)}
Expand Down
40 changes: 16 additions & 24 deletions apps/app/components/issues/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,30 +141,20 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = ({
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.",
});
});
};
Expand Down Expand Up @@ -194,14 +184,16 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = ({
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.",
});
});
};
Expand All @@ -211,8 +203,8 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = ({

const payload: Partial<IIssue> = {
...formData,
description: formData.description ? formData.description : "",
description_html: formData.description_html ? formData.description_html : "<p></p>",
description: formData.description ?? "",
description_html: formData.description_html ?? "<p></p>",
};

if (!data) await createIssue(payload);
Expand Down

1 comment on commit 4b06839

@vercel
Copy link

@vercel vercel bot commented on 4b06839 Feb 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

plane-dev – ./apps/app

plane-dev-caravel.vercel.app
plane-dev.vercel.app
plane-dev-git-develop-caravel.vercel.app

Please sign in to comment.