@@ -5,12 +5,16 @@ import { redirect } from 'next/navigation'
55import { createSearchParamsCache , createSerializer } from 'nuqs/server'
66import { EmptyState } from '@/components/empty-state/empty-state'
77import { getSession } from '@/lib/auth'
8- import { WORKSPACES_PATH } from '@/lib/navigation/paths'
8+ import { APP_ENTRY_PATH , organizationRoutes } from '@/lib/navigation/paths'
9+ import { getOrganizationSurfaceContext } from '@/lib/organizations/surface'
910import { buildAuthCrossLink } from '@/app/(auth)/auth-redirect'
1011import { AccessRequestsLoading } from '@/ee/access-requests/components/access-requests-loading'
1112import { MyAccessRequests } from '@/ee/access-requests/components/my-access-requests'
1213import { OrganizationAccessRequests } from '@/ee/access-requests/components/organization-access-requests'
13- import { accessRequestEntrySearchParams } from '@/ee/access-requests/components/search-params'
14+ import {
15+ accessRequestEntrySearchParams ,
16+ accessRequestSearchParams ,
17+ } from '@/ee/access-requests/components/search-params'
1418
1519export const metadata : Metadata = {
1620 title : 'Access requests' ,
@@ -23,6 +27,7 @@ interface AccessRequestsPageProps {
2327
2428const entrySearchParams = createSearchParamsCache ( accessRequestEntrySearchParams )
2529const serializeEntrySearchParams = createSerializer ( accessRequestEntrySearchParams )
30+ const serializeRequesterSearchParams = createSerializer ( accessRequestSearchParams )
2631
2732/** Session-only entry so access requests remain reachable outside the organization Search rollout. */
2833export default async function AccessRequestsPage ( { searchParams } : AccessRequestsPageProps ) {
@@ -41,26 +46,43 @@ export default async function AccessRequestsPage({ searchParams }: AccessRequest
4146 return (
4247 < EmptyState
4348 title = 'Choose an organization'
44- description = 'Open My access requests from your profile menu in a workspace.'
45- action = { < ChipLink href = { WORKSPACES_PATH } > Your workspaces </ ChipLink > }
49+ description = 'Open My access requests from your profile menu in an organization or workspace.'
50+ action = { < ChipLink href = { APP_ENTRY_PATH } > Back to Sim </ ChipLink > }
4651 />
4752 )
4853 }
4954
55+ if ( params . view !== 'admin' ) {
56+ const context = await getOrganizationSurfaceContext ( params . organizationId , session . user . id )
57+ if ( context ?. searchAccess . memberScoped ) {
58+ redirect (
59+ serializeRequesterSearchParams ( organizationRoutes ( params . organizationId ) . accessRequests , {
60+ view : params . view ,
61+ search : params . search ,
62+ page : params . page ,
63+ requestId : params . requestId ,
64+ } )
65+ )
66+ }
67+ }
68+
5069 return (
5170 < Suspense fallback = { < AccessRequestsLoading /> } >
5271 { params . view === 'admin' ? (
5372 < main className = 'flex-1 px-6 py-8' >
5473 < div className = 'mx-auto flex max-w-3xl flex-col gap-6' >
5574 < div className = 'flex items-center justify-between gap-4' >
5675 < h1 className = 'text-[var(--text-primary)] text-lg' > Access requests</ h1 >
57- < ChipLink href = { WORKSPACES_PATH } > Your workspaces </ ChipLink >
76+ < ChipLink href = { APP_ENTRY_PATH } > Back to Sim </ ChipLink >
5877 </ div >
5978 < OrganizationAccessRequests organizationId = { params . organizationId } standalone />
6079 </ div >
6180 </ main >
6281 ) : (
63- < MyAccessRequests scope = { { kind : 'organization' , organizationId : params . organizationId } } />
82+ < MyAccessRequests
83+ scope = { { kind : 'organization' , organizationId : params . organizationId } }
84+ standalone
85+ />
6486 ) }
6587 </ Suspense >
6688 )
0 commit comments