fix: remirror image not updating (#294)

This commit is contained in:
Aaryan Khandelwal 2023-02-17 16:57:31 +05:30 committed by GitHub
parent 1665863bd9
commit 4b068398bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 37 deletions

View File

@ -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

View File

@ -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;
@ -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 (
<>
@ -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..."
/>
)}

View File

@ -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.",
});
});
};
@ -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.",
});
});
};
@ -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);