Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

feat: redirect to default project

MonsProprebdf842c34647
diff --git a/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId.tsx b/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId.tsx
index 09c40c2dc..fb25b71de 100644
--- a/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId.tsx
+++ b/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId.tsx
@@ -1,8 +1,30 @@
-import { createFileRoute, Outlet } from "@tanstack/react-router";
+import { createFileRoute, Outlet, redirect } from "@tanstack/react-router";
+import getProjects from "@/fetchers/project/get-projects";
export const Route = createFileRoute(
"/_layout/_authenticated/dashboard/workspace/$workspaceId",
)({
+ beforeLoad: async ({ params, location }) => {
+ const currentPath = location.pathname.replace(/\/+$/, "");
+ const workspacePath = `/dashboard/workspace/${params.workspaceId}`;
+
+ if (currentPath !== workspacePath) return;
+
+ const projects = await getProjects({
+ workspaceId: params.workspaceId,
+ });
+
+ if (projects?.length !== 1) return;
+
+ throw redirect({
+ to: "/dashboard/workspace/$workspaceId/project/$projectId/board",
+ params: {
+ workspaceId: params.workspaceId,
+ projectId: projects[0].id,
+ },
+ replace: true,
+ });
+ },
component: RouteComponent,
});