From 7f7ffeaf479d72e6fbc6e2415c2c321b8ba3020a Mon Sep 17 00:00:00 2001 From: sharma01ketan Date: Fri, 11 Oct 2024 18:26:49 +0530 Subject: [PATCH] fix the logic --- .../calendar/quick-add-issue-actions.tsx | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/web/core/components/issues/issue-layouts/calendar/quick-add-issue-actions.tsx b/web/core/components/issues/issue-layouts/calendar/quick-add-issue-actions.tsx index a7a0a5c0acb..5a1becee227 100644 --- a/web/core/components/issues/issue-layouts/calendar/quick-add-issue-actions.tsx +++ b/web/core/components/issues/issue-layouts/calendar/quick-add-issue-actions.tsx @@ -8,7 +8,7 @@ import { PlusIcon } from "lucide-react"; // types import { ISearchIssueResponse, TIssue } from "@plane/types"; // ui -import { TOAST_TYPE, setToast, CustomMenu } from "@plane/ui"; +import { CustomMenu, setPromiseToast } from "@plane/ui"; // components import { ExistingIssuesListModal } from "@/components/core"; import { QuickAddIssueRoot } from "@/components/issues"; @@ -45,22 +45,21 @@ export const CalendarQuickAddIssueActions: FC = o if (!workspaceSlug || !projectId) return; const issueIds = data.map((i) => i.id); + const addExistingIssuesPromise = Promise.all( + data.map((issue) => updateIssue(workspaceSlug.toString(), projectId.toString(), issue.id, prePopulatedData ?? {})) + ).then(() => addIssuesToView?.(issueIds)); - try { - // To handle all updates in parallel - await Promise.all( - data.map((issue) => - updateIssue(workspaceSlug.toString(), projectId.toString(), issue.id, prePopulatedData ?? {}) - ) - ); - await addIssuesToView?.(issueIds); - } catch (error) { - setToast({ - type: TOAST_TYPE.ERROR, + setPromiseToast(addExistingIssuesPromise, { + loading: `Adding ${issueIds.length > 1 ? "issues" : "issue"} to cycle...`, + success: { + title: "Success!", + message: () => `${issueIds.length > 1 ? "Issues" : "Issue"} added to cycle successfully.`, + }, + error: { title: "Error!", - message: "Something went wrong. Please try again.", - }); - } + message: (err) => err?.message || "Something went wrong. Please try again.", + }, + }); }; const handleNewIssue = () => { @@ -130,4 +129,4 @@ export const CalendarQuickAddIssueActions: FC = o /> ); -}); +}); \ No newline at end of file