diff --git a/apps/dashboard/src/app/(app)/team/[team_slug]/(team)/layout.tsx b/apps/dashboard/src/app/(app)/team/[team_slug]/(team)/layout.tsx index 4780484b081..d30dcdd5391 100644 --- a/apps/dashboard/src/app/(app)/team/[team_slug]/(team)/layout.tsx +++ b/apps/dashboard/src/app/(app)/team/[team_slug]/(team)/layout.tsx @@ -1,9 +1,11 @@ import { getProjects } from "@/api/projects"; -import { getTeams } from "@/api/team"; +import { getTeamBySlug, getTeams } from "@/api/team"; import { AppFooter } from "@/components/blocks/app-footer"; +import { Button } from "@/components/ui/button"; import { TabPathLinks } from "@/components/ui/tabs"; import { getClientThirdwebClient } from "@/constants/thirdweb-client.client"; import { AnnouncementBanner } from "components/notices/AnnouncementBanner"; +import Link from "next/link"; import { redirect } from "next/navigation"; import { siwaExamplePrompts } from "../../../(dashboard)/support/page"; import { CustomChatButton } from "../../../../nebula-app/(app)/components/CustomChat/CustomChatButton"; @@ -20,25 +22,18 @@ export default async function TeamLayout(props: { }) { const params = await props.params; - const [accountAddress, account, teams, authToken] = await Promise.all([ + const [accountAddress, account, teams, authToken, team] = await Promise.all([ getAuthTokenWalletAddress(), getValidAccount(`/team/${params.team_slug}`), getTeams(), getAuthToken(), + getTeamBySlug(params.team_slug), ]); - if (!teams || !accountAddress || !authToken) { + if (!teams || !accountAddress || !authToken || !team) { redirect("/login"); } - const team = teams.find( - (t) => t.slug === decodeURIComponent(params.team_slug), - ); - - if (!team) { - redirect("/team"); - } - const teamsAndProjects = await Promise.all( teams.map(async (team) => ({ team, @@ -53,6 +48,21 @@ export default async function TeamLayout(props: { return (
+ {!teams.some((t) => t.slug === team.slug) && ( +
+
+
+

👀 STAFF MODE 👀

+

+ You can only view this team, not take any actions. +

+
+ +
+
+ )}
; }) { const params = await props.params; - const [accountAddress, teams, account, authToken] = await Promise.all([ - getAuthTokenWalletAddress(), - getTeams(), - getValidAccount(`/team/${params.team_slug}/${params.project_slug}`), - getAuthToken(), - ]); + const [accountAddress, teams, account, authToken, team, project] = + await Promise.all([ + getAuthTokenWalletAddress(), + getTeams(), + getValidAccount(`/team/${params.team_slug}/${params.project_slug}`), + getAuthToken(), + getTeamBySlug(params.team_slug), + getProject(params.team_slug, params.project_slug), + ]); if (!teams || !accountAddress || !authToken) { redirect("/login"); } - const team = teams.find( - (t) => t.slug === decodeURIComponent(params.team_slug), - ); - if (!team) { redirect("/team"); } @@ -47,10 +48,6 @@ export default async function ProjectLayout(props: { })), ); - const project = teamsAndProjects - .find((t) => t.team.slug === decodeURIComponent(params.team_slug)) - ?.projects.find((p) => p.slug === params.project_slug); - if (!project) { // not a valid project, redirect back to team page redirect(`/team/${params.team_slug}`); @@ -65,6 +62,21 @@ export default async function ProjectLayout(props: { return (
+ {!teams.some((t) => t.slug === team.slug) && ( +
+
+
+

👀 STAFF MODE 👀

+

+ You can only view this team, not take any actions. +

+
+ +
+
+ )}
- - - {currentTeam.name} - + + + + {currentTeam.name} + + + {/* may render its own link so has to be outside of the link */} - +