Teams context settings.

This commit is contained in:
Mike Cao 2024-02-02 17:49:17 -08:00
parent 4429198397
commit 8f853ddb97
77 changed files with 317 additions and 272 deletions

View file

@ -0,0 +1,17 @@
import { usePathname } from 'next/navigation';
export function useTeamContext(): {
teamId?: string;
renderTeamUrl: (url: string) => string;
} {
const pathname = usePathname();
const [, teamId] = pathname.match(/^\/teams\/([a-f0-9-]+)/) || [];
function renderTeamUrl(url: string) {
return teamId ? `/teams/${teamId}${url}` : url;
}
return { teamId, renderTeamUrl };
}
export default useTeamContext;