1
1
import { ShellMainAppDir } from "app/(use-page-wrapper)/(main-nav)/ShellMainAppDir" ;
2
- import { withAppDirSsr } from "app/WithAppDirSsr" ;
3
2
import type { PageProps as ServerPageProps } from "app/_types" ;
4
3
import { _generateMetadata , getTranslate } from "app/_utils" ;
5
4
import { cookies , headers } from "next/headers" ;
5
+ import { redirect } from "next/navigation" ;
6
6
7
- import { buildLegacyCtx } from "@lib/buildLegacyCtx" ;
8
- import { getServerSideProps } from "@lib/teams/getServerSideProps" ;
7
+ import { getServerSession } from "@calcom/features/auth/lib/getServerSession" ;
8
+
9
+ import { buildLegacyRequest } from "@lib/buildLegacyCtx" ;
9
10
10
- import type { PageProps as ClientPageProps } from "~/teams/teams-view" ;
11
11
import TeamsView , { TeamsCTA } from "~/teams/teams-view" ;
12
12
13
13
export const generateMetadata = async ( ) =>
@@ -16,19 +16,23 @@ export const generateMetadata = async () =>
16
16
( t ) => t ( "create_manage_teams_collaborative" )
17
17
) ;
18
18
19
- const getData = withAppDirSsr < ClientPageProps > ( getServerSideProps ) ;
19
+ const ServerPage = async ( { searchParams } : ServerPageProps ) => {
20
+ const session = await getServerSession ( { req : buildLegacyRequest ( headers ( ) , cookies ( ) ) } ) ;
21
+ const token = Array . isArray ( searchParams ?. token ) ? searchParams . token [ 0 ] : searchParams ?. token ;
22
+ const callbackUrl = token ? `/teams?token=${ encodeURIComponent ( token ) } ` : null ;
23
+
24
+ if ( ! session ) {
25
+ redirect ( callbackUrl ? `/auth/login?callbackUrl=${ callbackUrl } ` : "/auth/login" ) ;
26
+ }
20
27
21
- const ServerPage = async ( { params, searchParams } : ServerPageProps ) => {
22
- const context = buildLegacyCtx ( headers ( ) , cookies ( ) , params , searchParams ) ;
23
- const props = await getData ( context ) ;
24
28
const t = await getTranslate ( ) ;
25
29
26
30
return (
27
31
< ShellMainAppDir
28
32
CTA = { < TeamsCTA /> }
29
33
heading = { t ( "teams" ) }
30
34
subtitle = { t ( "create_manage_teams_collaborative" ) } >
31
- < TeamsView { ... props } />
35
+ < TeamsView />
32
36
</ ShellMainAppDir >
33
37
) ;
34
38
} ;
0 commit comments