Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remirror image not updating #294

Merged
merged 1 commit into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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