Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

handle delete workspace

Steven Tey69db356f0828
diff --git a/apps/web/lib/api/workspaces.ts b/apps/web/lib/api/workspaces.ts
index 35e9ad1e89..bae2765cd4 100644
--- a/apps/web/lib/api/workspaces.ts
+++ b/apps/web/lib/api/workspaces.ts
@@ -111,6 +111,14 @@ export async function deleteWorkspace(
slug: workspace.slug,
},
}),
+ prisma.user.updateMany({
+ where: {
+ defaultWorkspace: workspace.slug,
+ },
+ data: {
+ defaultWorkspace: null,
+ },
+ }),
]);
})(),
);
diff --git a/apps/web/ui/modals/delete-workspace-modal.tsx b/apps/web/ui/modals/delete-workspace-modal.tsx
index d575d5403f..f55bbb3994 100644
--- a/apps/web/ui/modals/delete-workspace-modal.tsx
+++ b/apps/web/ui/modals/delete-workspace-modal.tsx
@@ -36,7 +36,7 @@ function DeleteWorkspaceModal({
}).then(async (res) => {
if (res.ok) {
await mutate("/api/workspaces");
- router.push("/");
+ router.push("/workspaces");
resolve(null);
} else {
setDeleting(false);