From 7361657660f2e494bbabadda08a3fe0af1a72266 Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Date: Thu, 13 Jul 2023 19:00:43 +0530 Subject: [PATCH] fix: issue delete redirection, chore: code refactor (#1521) --- .../automation/auto-archive-automation.tsx | 12 +++++------- .../automation/auto-close-automation.tsx | 12 +++++------- apps/app/components/issues/delete-issue-modal.tsx | 14 ++++++-------- .../projects/[projectId]/settings/automations.tsx | 9 +++++++-- 4 files changed, 23 insertions(+), 24 deletions(-) diff --git a/apps/app/components/automation/auto-archive-automation.tsx b/apps/app/components/automation/auto-archive-automation.tsx index b8321548a..8d1ba4ebe 100644 --- a/apps/app/components/automation/auto-archive-automation.tsx +++ b/apps/app/components/automation/auto-archive-automation.tsx @@ -39,13 +39,11 @@ export const AutoArchiveAutomation: React.FC = ({ projectDetails, handleC { - if (projectDetails?.archive_in === 0) { - handleChange({ archive_in: 1 }); - } else { - handleChange({ archive_in: 0 }); - } - }} + onChange={() => + projectDetails?.archive_in === 0 + ? handleChange({ archive_in: 1 }) + : handleChange({ archive_in: 0 }) + } size="sm" /> diff --git a/apps/app/components/automation/auto-close-automation.tsx b/apps/app/components/automation/auto-close-automation.tsx index 907cf50ee..4d46069e9 100644 --- a/apps/app/components/automation/auto-close-automation.tsx +++ b/apps/app/components/automation/auto-close-automation.tsx @@ -88,13 +88,11 @@ export const AutoCloseAutomation: React.FC = ({ projectDetails, handleCha { - if (projectDetails?.close_in === 0) { - handleChange({ close_in: 1, default_state: defaultState }); - } else { - handleChange({ close_in: 0, default_state: null }); - } - }} + onChange={() => + projectDetails?.close_in === 0 + ? handleChange({ close_in: 1, default_state: defaultState }) + : handleChange({ close_in: 0, default_state: null }) + } size="sm" /> diff --git a/apps/app/components/issues/delete-issue-modal.tsx b/apps/app/components/issues/delete-issue-modal.tsx index ee8806746..7a58dd251 100644 --- a/apps/app/components/issues/delete-issue-modal.tsx +++ b/apps/app/components/issues/delete-issue-modal.tsx @@ -121,6 +121,7 @@ export const DeleteIssueModal: React.FC = ({ isOpen, handleClose, data, u type: "success", message: "Issue deleted successfully", }); + router.back(); }) .catch((error) => { console.log(error); @@ -142,7 +143,7 @@ export const DeleteIssueModal: React.FC = ({ isOpen, handleClose, data, u type: "success", message: "Issue deleted successfully", }); - router.push(`/${workspaceSlug}/projects/${projectId}/archived-issues/`); + router.back(); }) .catch((error) => { console.log(error); @@ -150,6 +151,9 @@ export const DeleteIssueModal: React.FC = ({ isOpen, handleClose, data, u }); }; + const handleIssueDelete = () => + isArchivedIssues ? handleArchivedIssueDeletion() : handleDeletion(); + return ( @@ -201,13 +205,7 @@ export const DeleteIssueModal: React.FC = ({ isOpen, handleClose, data, u
Cancel - { - if (isArchivedIssues) handleArchivedIssueDeletion(); - else handleDeletion(); - }} - loading={isDeleteLoading} - > + {isDeleteLoading ? "Deleting..." : "Delete Issue"}
diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/automations.tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/automations.tsx index c96674c01..a2cb01a55 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/automations.tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/automations.tsx @@ -21,7 +21,7 @@ import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs"; import type { NextPage } from "next"; import { IProject } from "types"; // constant -import { PROJECT_DETAILS } from "constants/fetch-keys"; +import { PROJECTS_LIST, PROJECT_DETAILS } from "constants/fetch-keys"; const AutomationsSettings: NextPage = () => { const router = useRouter(); @@ -40,10 +40,15 @@ const AutomationsSettings: NextPage = () => { (prevData) => ({ ...(prevData as IProject), ...formData }), false ); - await projectService .updateProject(workspaceSlug as string, projectId as string, formData, user) .then(() => { + mutate( + PROJECTS_LIST(workspaceSlug as string), + (prevData) => + (prevData ?? []).map((p) => (p.id === projectDetails?.id ? { ...p, ...formData } : p)), + false + ); mutate(PROJECT_DETAILS(projectId as string)); }) .catch(() => {