fix pathname

This commit is contained in:
2026-01-20 15:21:42 -03:00
parent 0e036d0d4f
commit 2cd000c1cb
2 changed files with 43 additions and 36 deletions

View File

@@ -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({

View File

@@ -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,45 +85,47 @@ export default function Route({ loaderData }: Route.ComponentProps) {
</AlertDialog> </AlertDialog>
) : null} ) : null}
<SidebarProvider <WorkspaceProvider {...props}>
defaultOpen={sidebar_state === 'true'} <SidebarProvider
className={cn('flex', blocked && 'pointer-events-none')} defaultOpen={sidebar_state === 'true'}
> className={cn('flex', blocked && 'pointer-events-none')}
<AppSidebar /> >
<AppSidebar />
<SidebarInset className="relative flex flex-col flex-1 min-w-0"> <SidebarInset className="relative flex flex-col flex-1 min-w-0">
<header <header
className="bg-background/15 backdrop-blur-sm className="bg-background/15 backdrop-blur-sm
px-4 py-2 lg:py-4 sticky top-0 z-10" px-4 py-2 lg:py-4 sticky top-0 z-10"
> >
<div className="container mx-auto flex items-center max-w-7xl"> <div className="container mx-auto flex items-center max-w-7xl">
<SidebarTrigger className="md:hidden" /> <SidebarTrigger className="md:hidden" />
<ThemedImage className="max-md:hidden" /> <ThemedImage className="max-md:hidden" />
<div className="ml-auto flex gap-2.5 items-center"> <div className="ml-auto flex gap-2.5 items-center">
<TestMode /> <TestMode />
{/*<Notification />*/} {/*<Notification />*/}
<ModeToggle /> <ModeToggle />
<NavUser user={user} excludeApps={['admin']} /> <NavUser user={user} excludeApps={['admin']} />
</div>
</div>
</header>
<div className="p-4">
<div className="container mx-auto relative max-w-7xl">
<Outlet />
<Toaster
position="top-center"
richColors={true}
duration={Infinity}
closeButton={true}
/>
</div> </div>
</div> </div>
</header> </SidebarInset>
</SidebarProvider>
<div className="p-4"> </WorkspaceProvider>
<div className="container mx-auto relative max-w-7xl"> </>
<Outlet />
<Toaster
position="top-center"
richColors={true}
duration={Infinity}
closeButton={true}
/>
</div>
</div>
</SidebarInset>
</SidebarProvider>
</WorkspaceProvider>
) )
} }