fix pathname
This commit is contained in:
@@ -41,6 +41,7 @@ export const workspaceMiddleware = async (
|
|||||||
{ params, request, context }: LoaderFunctionArgs,
|
{ params, request, context }: LoaderFunctionArgs,
|
||||||
next: () => Promise<Response>
|
next: () => Promise<Response>
|
||||||
): Promise<Response> => {
|
): Promise<Response> => {
|
||||||
|
const url = new URL(request.url)
|
||||||
const user = context.get(userContext)!
|
const user = context.get(userContext)!
|
||||||
|
|
||||||
const r = await req({
|
const r = await req({
|
||||||
@@ -66,7 +67,11 @@ export const workspaceMiddleware = async (
|
|||||||
? (workspaces.find(({ id }) => id === preferred_org_id) ?? workspaces[0])
|
? (workspaces.find(({ id }) => id === preferred_org_id) ?? workspaces[0])
|
||||||
: workspaces[0]
|
: workspaces[0]
|
||||||
|
|
||||||
throw redirect(`/${fallback.id}/main`)
|
if (!fallback) {
|
||||||
|
throw new Response(null, { status: 403 })
|
||||||
|
}
|
||||||
|
|
||||||
|
throw redirect(`/${fallback.id}${url.pathname}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const org = (await req({
|
const org = (await req({
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ export default function Route({ loaderData }: Route.ComponentProps) {
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WorkspaceProvider {...props}>
|
<>
|
||||||
{blocked ? (
|
{blocked ? (
|
||||||
<AlertDialog open={true}>
|
<AlertDialog open={true}>
|
||||||
<AlertDialogContent>
|
<AlertDialogContent>
|
||||||
@@ -85,6 +85,7 @@ export default function Route({ loaderData }: Route.ComponentProps) {
|
|||||||
</AlertDialog>
|
</AlertDialog>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
<WorkspaceProvider {...props}>
|
||||||
<SidebarProvider
|
<SidebarProvider
|
||||||
defaultOpen={sidebar_state === 'true'}
|
defaultOpen={sidebar_state === 'true'}
|
||||||
className={cn('flex', blocked && 'pointer-events-none')}
|
className={cn('flex', blocked && 'pointer-events-none')}
|
||||||
@@ -124,6 +125,7 @@ export default function Route({ loaderData }: Route.ComponentProps) {
|
|||||||
</SidebarInset>
|
</SidebarInset>
|
||||||
</SidebarProvider>
|
</SidebarProvider>
|
||||||
</WorkspaceProvider>
|
</WorkspaceProvider>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user