From bb0504065b59b29c604c7b73c45d940835d029c5 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 2 Feb 2024 22:30:01 -0800 Subject: [PATCH] Handle when team not found. --- src/app/(main)/teams/[teamId]/Team.tsx | 21 +++++++++++++++++++++ src/app/(main)/teams/[teamId]/layout.tsx | 5 +++++ 2 files changed, 26 insertions(+) create mode 100644 src/app/(main)/teams/[teamId]/Team.tsx create mode 100644 src/app/(main)/teams/[teamId]/layout.tsx diff --git a/src/app/(main)/teams/[teamId]/Team.tsx b/src/app/(main)/teams/[teamId]/Team.tsx new file mode 100644 index 00000000..631fdaf1 --- /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 ; + } + + 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 00000000..1f887ce8 --- /dev/null +++ b/src/app/(main)/teams/[teamId]/layout.tsx @@ -0,0 +1,5 @@ +import Team from './Team'; + +export default function ({ children }) { + return {children}; +}