fix when does not find a workspace

This commit is contained in:
2026-01-20 14:51:20 -03:00
parent b3e60aea65
commit 9aca2bb223
3 changed files with 11 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
import { createContext, type LoaderFunctionArgs } from 'react-router'
import { createContext, redirect, type LoaderFunctionArgs } from 'react-router'
import { userContext } from '@repo/auth/context'
import { request as req } from '@repo/util/request'
@@ -52,9 +52,12 @@ export const workspaceMiddleware = async (
return { ...props, id }
}) as Workspace[]
const activeWorkspace = workspaces.find(
({ id }) => id === org_id
) as Workspace
const activeWorkspace = workspaces.find(({ id }) => id === org_id)
if (!activeWorkspace) {
const { id } = workspaces[0]
throw redirect(`/${id}/main`)
}
const org = (await req({
url: `/orgs/${activeWorkspace.id}`,