Updates to team components.
This commit is contained in:
18
src/components/hooks/useTeamUrl.ts
Normal file
18
src/components/hooks/useTeamUrl.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
'use client';
|
||||
import { usePathname } from 'next/navigation';
|
||||
|
||||
export function useTeamUrl(): {
|
||||
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 useTeamUrl;
|
||||
Reference in New Issue
Block a user