Handle when team not found.
This commit is contained in:
21
src/app/(main)/teams/[teamId]/Team.tsx
Normal file
21
src/app/(main)/teams/[teamId]/Team.tsx
Normal file
@@ -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;
|
||||||
5
src/app/(main)/teams/[teamId]/layout.tsx
Normal file
5
src/app/(main)/teams/[teamId]/layout.tsx
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import Team from './Team';
|
||||||
|
|
||||||
|
export default function ({ children }) {
|
||||||
|
return <Team>{children}</Team>;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user