mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 22:57:12 +01:00
Teams context settings.
This commit is contained in:
parent
4429198397
commit
8f853ddb97
77 changed files with 317 additions and 272 deletions
17
src/components/hooks/useTeamContext.ts
Normal file
17
src/components/hooks/useTeamContext.ts
Normal 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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue