Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Handle when team not found.

Mike Caobb0504065b59
diff --git a/src/app/(main)/teams/[teamId]/Team.tsx b/src/app/(main)/teams/[teamId]/Team.tsx
new file mode 100644
index 000000000..631fdaf12
--- /dev/null
+++ b/src/app/(main)/teams/[teamId]/Team.tsx
@@ -0,0 +1,21 @@
+'use client';
+import { useTeam, useTeamContext } from 'components/hooks';
+import { Loading } from 'react-basics';
+import notFound from 'app/not-found';
+
+export function Team({ children }) {
+ const { teamId } = useTeamContext();
+ const { data: team, isLoading } = useTeam(teamId);
+
+ if (isLoading) {
+ return <Loading />;
+ }
+
+ if (!team) {
+ return notFound();
+ }
+
+ return children;
+}
+
+export default Team;
diff --git a/src/app/(main)/teams/[teamId]/layout.tsx b/src/app/(main)/teams/[teamId]/layout.tsx
new file mode 100644
index 000000000..1f887ce8a
--- /dev/null
+++ b/src/app/(main)/teams/[teamId]/layout.tsx
@@ -0,0 +1,5 @@
+import Team from './Team';
+
+export default function ({ children }) {
+ return <Team>{children}</Team>;
+}