diff --git a/web/components/issues/issue-layouts/calendar/base-calendar-root.tsx b/web/components/issues/issue-layouts/calendar/base-calendar-root.tsx index 6b8497f2b..1d70e2289 100644 --- a/web/components/issues/issue-layouts/calendar/base-calendar-root.tsx +++ b/web/components/issues/issue-layouts/calendar/base-calendar-root.tsx @@ -4,6 +4,8 @@ import { observer } from "mobx-react-lite"; import { DragDropContext, DropResult } from "@hello-pangea/dnd"; // components import { CalendarChart, IssuePeekOverview } from "components/issues"; +// hooks +import useToast from "hooks/use-toast"; // types import { IIssue } from "types"; import { @@ -34,7 +36,7 @@ interface IBaseCalendarRoot { [EIssueActions.REMOVE]?: (issue: IIssue) => Promise; }; viewId?: string; - handleDragDrop: (source: any, destination: any, issues: any, issueWithIds: any) => void; + handleDragDrop: (source: any, destination: any, issues: any, issueWithIds: any) => Promise; } export const BaseCalendarRoot = observer((props: IBaseCalendarRoot) => { @@ -44,12 +46,15 @@ export const BaseCalendarRoot = observer((props: IBaseCalendarRoot) => { const router = useRouter(); const { workspaceSlug, peekIssueId, peekProjectId } = router.query; + // hooks + const { setToastAlert } = useToast(); + const displayFilters = issuesFilterStore.issueFilters?.displayFilters; const issues = issueStore.getIssues; const groupedIssueIds = (issueStore.getIssuesIds ?? {}) as IGroupedIssues; - const onDragEnd = (result: DropResult) => { + const onDragEnd = async (result: DropResult) => { if (!result) return; // return if not dropped on the correct place @@ -58,7 +63,15 @@ export const BaseCalendarRoot = observer((props: IBaseCalendarRoot) => { // return if dropped on the same date if (result.destination.droppableId === result.source.droppableId) return; - if (handleDragDrop) handleDragDrop(result.source, result.destination, issues, groupedIssueIds); + if (handleDragDrop) { + await handleDragDrop(result.source, result.destination, issues, groupedIssueIds).catch((err) => { + setToastAlert({ + title: "Error", + type: "error", + message: err.detail ?? "Failed to perform this action", + }); + }); + } }; const handleIssues = useCallback( diff --git a/web/components/issues/issue-layouts/calendar/roots/cycle-root.tsx b/web/components/issues/issue-layouts/calendar/roots/cycle-root.tsx index 9830b871f..f9a4bd9a0 100644 --- a/web/components/issues/issue-layouts/calendar/roots/cycle-root.tsx +++ b/web/components/issues/issue-layouts/calendar/roots/cycle-root.tsx @@ -41,9 +41,9 @@ export const CycleCalendarLayout: React.FC = observer(() => { }, }; - const handleDragDrop = (source: any, destination: any, issues: IIssue[], issueWithIds: any) => { + const handleDragDrop = async (source: any, destination: any, issues: IIssue[], issueWithIds: any) => { if (workspaceSlug && projectId && cycleId) - handleCalenderDragDrop( + await handleCalenderDragDrop( source, destination, workspaceSlug.toString(), diff --git a/web/components/issues/issue-layouts/calendar/roots/module-root.tsx b/web/components/issues/issue-layouts/calendar/roots/module-root.tsx index bff618820..187c05f6a 100644 --- a/web/components/issues/issue-layouts/calendar/roots/module-root.tsx +++ b/web/components/issues/issue-layouts/calendar/roots/module-root.tsx @@ -38,8 +38,8 @@ export const ModuleCalendarLayout: React.FC = observer(() => { }, }; - const handleDragDrop = (source: any, destination: any, issues: IIssue[], issueWithIds: any) => { - handleCalenderDragDrop( + const handleDragDrop = async (source: any, destination: any, issues: IIssue[], issueWithIds: any) => { + await handleCalenderDragDrop( source, destination, workspaceSlug, diff --git a/web/components/issues/issue-layouts/calendar/roots/project-root.tsx b/web/components/issues/issue-layouts/calendar/roots/project-root.tsx index d5bbce1fc..e71cc7e3b 100644 --- a/web/components/issues/issue-layouts/calendar/roots/project-root.tsx +++ b/web/components/issues/issue-layouts/calendar/roots/project-root.tsx @@ -31,9 +31,9 @@ export const CalendarLayout: React.FC = observer(() => { }, }; - const handleDragDrop = (source: any, destination: any, issues: IIssue[], issueWithIds: any) => { + const handleDragDrop = async (source: any, destination: any, issues: IIssue[], issueWithIds: any) => { if (workspaceSlug && projectId) - handleCalenderDragDrop( + await handleCalenderDragDrop( source, destination, workspaceSlug.toString(), diff --git a/web/components/issues/issue-layouts/calendar/roots/project-view-root.tsx b/web/components/issues/issue-layouts/calendar/roots/project-view-root.tsx index c73b3b2f8..95d746eec 100644 --- a/web/components/issues/issue-layouts/calendar/roots/project-view-root.tsx +++ b/web/components/issues/issue-layouts/calendar/roots/project-view-root.tsx @@ -32,9 +32,9 @@ export const ProjectViewCalendarLayout: React.FC = observer(() => { }, }; - const handleDragDrop = (source: any, destination: any, issues: IIssue[], issueWithIds: any) => { + const handleDragDrop = async (source: any, destination: any, issues: IIssue[], issueWithIds: any) => { if (workspaceSlug && projectId) - handleCalenderDragDrop( + await handleCalenderDragDrop( source, destination, workspaceSlug.toString(), diff --git a/web/components/issues/issue-layouts/gantt/quick-add-issue-form.tsx b/web/components/issues/issue-layouts/gantt/quick-add-issue-form.tsx index 48931e4ee..e4a88e944 100644 --- a/web/components/issues/issue-layouts/gantt/quick-add-issue-form.tsx +++ b/web/components/issues/issue-layouts/gantt/quick-add-issue-form.tsx @@ -121,8 +121,9 @@ export const GanttInlineCreateIssueForm: React.FC = observer((props) => { }); try { - quickAddCallback && quickAddCallback(workspaceSlug, projectId, payload, viewId); - + if (quickAddCallback) { + await quickAddCallback(workspaceSlug, projectId, payload, viewId); + } setToastAlert({ type: "success", title: "Success!", diff --git a/web/components/issues/issue-layouts/kanban/base-kanban-root.tsx b/web/components/issues/issue-layouts/kanban/base-kanban-root.tsx index 7256e2611..57ab8418c 100644 --- a/web/components/issues/issue-layouts/kanban/base-kanban-root.tsx +++ b/web/components/issues/issue-layouts/kanban/base-kanban-root.tsx @@ -147,7 +147,7 @@ export const BaseKanBanRoot: React.FC = observer((props: IBas setIsDragStarted(true); }; - const onDragEnd = (result: DropResult) => { + const onDragEnd = async (result: DropResult) => { setIsDragStarted(false); if (!result) return; @@ -171,7 +171,15 @@ export const BaseKanBanRoot: React.FC = observer((props: IBas }); setDeleteIssueModal(true); } else { - handleDragDrop(result.source, result.destination, sub_group_by, group_by, issues, issueIds); + await handleDragDrop(result.source, result.destination, sub_group_by, group_by, issues, issueIds).catch( + (err) => { + setToastAlert({ + title: "Error", + type: "error", + message: err.detail ?? "Failed to perform this action", + }); + } + ); } } }; diff --git a/web/store/issues/base-issue-calendar-helper.store.ts b/web/store/issues/base-issue-calendar-helper.store.ts index 4eeee8418..5bc66cd38 100644 --- a/web/store/issues/base-issue-calendar-helper.store.ts +++ b/web/store/issues/base-issue-calendar-helper.store.ts @@ -45,8 +45,8 @@ export class CalendarHelpers implements ICalendarHelpers { target_date: destinationColumnId, }; - if (viewId) store?.updateIssue(workspaceSlug, projectId, updateIssue.id, updateIssue, viewId); - else store?.updateIssue(workspaceSlug, projectId, updateIssue.id, updateIssue); + if (viewId) return await store?.updateIssue(workspaceSlug, projectId, updateIssue.id, updateIssue, viewId); + else return await store?.updateIssue(workspaceSlug, projectId, updateIssue.id, updateIssue); } } };