From bf0d0503b2bf41c091405372a3110eb2658e2937 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Fri, 25 Aug 2023 12:17:17 +0530 Subject: [PATCH] fix: redirection after deleting a project (#1970) Co-authored-by: Aaryan Khandelwal --- apps/app/components/project/delete-project-modal.tsx | 4 +++- .../[workspaceSlug]/projects/[projectId]/settings/index.tsx | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/app/components/project/delete-project-modal.tsx b/apps/app/components/project/delete-project-modal.tsx index 5b271d99d..d6f7ba0f0 100644 --- a/apps/app/components/project/delete-project-modal.tsx +++ b/apps/app/components/project/delete-project-modal.tsx @@ -42,7 +42,7 @@ export const DeleteProjectModal: React.FC = ({ user, }) => { const router = useRouter(); - const { workspaceSlug } = router.query; + const { workspaceSlug, projectId } = router.query; const { setToastAlert } = useToast(); @@ -81,6 +81,8 @@ export const DeleteProjectModal: React.FC = ({ ); if (onSuccess) onSuccess(); + + if (projectId && projectId === data.id) router.push(`/${workspaceSlug}/projects`); }) .catch(() => setToastAlert({ diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/index.tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/index.tsx index 4287cee5d..57bf4fa3c 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/index.tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/index.tsx @@ -183,9 +183,6 @@ const GeneralSettings: NextPage = () => { data={projectDetails ?? null} isOpen={Boolean(selectProject)} onClose={() => setSelectedProject(null)} - onSuccess={() => { - router.push(`/${workspaceSlug}/projects`); - }} user={user} />