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.

Redirect to default workspace

Steven Teyf32055ac612a
diff --git a/apps/web/app/app.dub.co/(dashboard)/page.tsx b/apps/web/app/app.dub.co/(dashboard)/workspaces/page.tsx
similarity index 94%
rename from apps/web/app/app.dub.co/(dashboard)/page.tsx
rename to apps/web/app/app.dub.co/(dashboard)/workspaces/page.tsx
index b7c3bf03e2..9d00d66d4b 100644
--- a/apps/web/app/app.dub.co/(dashboard)/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/workspaces/page.tsx
@@ -2,7 +2,7 @@ import CreateWorkspaceButton from "@/ui/workspaces/create-workspace-button";
import WorkspaceList from "@/ui/workspaces/workspace-list";
import { MaxWidthWrapper } from "@dub/ui";
-export default function App() {
+export default function Workspaces() {
return (
<>
<div className="flex h-36 items-center border-b border-gray-200 bg-white">
diff --git a/apps/web/lib/middleware/app.ts b/apps/web/lib/middleware/app.ts
index 03e94ed205..6298f5ac4a 100644
--- a/apps/web/lib/middleware/app.ts
+++ b/apps/web/lib/middleware/app.ts
@@ -1,6 +1,7 @@
import { parse } from "@/lib/middleware/utils";
import { NextRequest, NextResponse } from "next/server";
import NewLinkMiddleware from "./new-link";
+import { getDefaultWorkspace } from "./utils/get-default-workspace";
import { getUserViaToken } from "./utils/get-user-via-token";
export default async function AppMiddleware(req: NextRequest) {
@@ -37,9 +38,11 @@ export default async function AppMiddleware(req: NextRequest) {
) {
return NextResponse.redirect(new URL("/welcome", req.url));
- // if the path is /login or /register, redirect to "/"
- } else if (path === "/login" || path === "/register") {
- return NextResponse.redirect(new URL("/", req.url));
+ // if the path is / or /login or /register, redirect to the default workspace
+ } else if (path === "/" || path === "/login" || path === "/register") {
+ const defaultWorkspace = await getDefaultWorkspace(user);
+
+ return NextResponse.redirect(new URL(`/${defaultWorkspace}`, req.url));
}
}
diff --git a/apps/web/ui/layout/workspace-switcher.tsx b/apps/web/ui/layout/workspace-switcher.tsx
index ba5bffc8db..d827f797de 100644
--- a/apps/web/ui/layout/workspace-switcher.tsx
+++ b/apps/web/ui/layout/workspace-switcher.tsx
@@ -138,7 +138,16 @@ function WorkspaceList({
return (
<div className="relative mt-1 max-h-72 w-full space-y-0.5 overflow-auto rounded-md bg-white p-2 text-base sm:w-60 sm:text-sm sm:shadow-lg">
- <div className="p-2 text-xs text-gray-500">My Workspaces</div>
+ <div className="flex items-center justify-between px-2 pb-1">
+ <p className="text-xs text-gray-500">My Workspaces</p>
+ <Link
+ href="/workspaces"
+ onClick={() => setOpenPopover(false)}
+ className="rounded-md border border-gray-200 px-2 py-1 text-xs transition-colors hover:bg-gray-100"
+ >
+ View All
+ </Link>
+ </div>
{workspaces.map(({ id, name, slug, logo }) => {
return (
<Link