1
- import { getProjects } from "@/api/projects" ;
2
- import { getTeams } from "@/api/team" ;
1
+ import { getProject , getProjects } from "@/api/projects" ;
2
+ import { getTeamBySlug , getTeams } from "@/api/team" ;
3
+ import { Button } from "@/components/ui/button" ;
3
4
import { SidebarProvider } from "@/components/ui/sidebar" ;
4
5
import { getClientThirdwebClient } from "@/constants/thirdweb-client.client" ;
5
6
import { AnnouncementBanner } from "components/notices/AnnouncementBanner" ;
7
+ import Link from "next/link" ;
6
8
import { redirect } from "next/navigation" ;
7
9
import { siwaExamplePrompts } from "../../../../(dashboard)/support/page" ;
8
10
import { CustomChatButton } from "../../../../../nebula-app/(app)/components/CustomChat/CustomChatButton" ;
@@ -21,21 +23,20 @@ export default async function ProjectLayout(props: {
21
23
params : Promise < { team_slug : string ; project_slug : string } > ;
22
24
} ) {
23
25
const params = await props . params ;
24
- const [ accountAddress , teams , account , authToken ] = await Promise . all ( [
25
- getAuthTokenWalletAddress ( ) ,
26
- getTeams ( ) ,
27
- getValidAccount ( `/team/${ params . team_slug } /${ params . project_slug } ` ) ,
28
- getAuthToken ( ) ,
29
- ] ) ;
26
+ const [ accountAddress , teams , account , authToken , team , project ] =
27
+ await Promise . all ( [
28
+ getAuthTokenWalletAddress ( ) ,
29
+ getTeams ( ) ,
30
+ getValidAccount ( `/team/${ params . team_slug } /${ params . project_slug } ` ) ,
31
+ getAuthToken ( ) ,
32
+ getTeamBySlug ( params . team_slug ) ,
33
+ getProject ( params . team_slug , params . project_slug ) ,
34
+ ] ) ;
30
35
31
36
if ( ! teams || ! accountAddress || ! authToken ) {
32
37
redirect ( "/login" ) ;
33
38
}
34
39
35
- const team = teams . find (
36
- ( t ) => t . slug === decodeURIComponent ( params . team_slug ) ,
37
- ) ;
38
-
39
40
if ( ! team ) {
40
41
redirect ( "/team" ) ;
41
42
}
@@ -47,10 +48,6 @@ export default async function ProjectLayout(props: {
47
48
} ) ) ,
48
49
) ;
49
50
50
- const project = teamsAndProjects
51
- . find ( ( t ) => t . team . slug === decodeURIComponent ( params . team_slug ) )
52
- ?. projects . find ( ( p ) => p . slug === params . project_slug ) ;
53
-
54
51
if ( ! project ) {
55
52
// not a valid project, redirect back to team page
56
53
redirect ( `/team/${ params . team_slug } ` ) ;
@@ -65,6 +62,21 @@ export default async function ProjectLayout(props: {
65
62
return (
66
63
< SidebarProvider >
67
64
< div className = "flex h-dvh min-w-0 grow flex-col" >
65
+ { ! teams . some ( ( t ) => t . slug === team . slug ) && (
66
+ < div className = "bg-warning-text" >
67
+ < div className = "container flex items-center justify-between py-4" >
68
+ < div className = "flex flex-col gap-2" >
69
+ < p className = "font-bold text-white text-xl" > 👀 STAFF MODE 👀</ p >
70
+ < p className = "text-sm text-white" >
71
+ You can only view this team, not take any actions.
72
+ </ p >
73
+ </ div >
74
+ < Button variant = "default" asChild >
75
+ < Link href = "/team/~" > Leave Staff Mode</ Link >
76
+ </ Button >
77
+ </ div >
78
+ </ div >
79
+ ) }
68
80
< div className = "sticky top-0 z-10 border-border border-b bg-card" >
69
81
< AnnouncementBanner />
70
82
< TeamHeaderLoggedIn
0 commit comments