40 lines
900 B
TypeScript
40 lines
900 B
TypeScript
import { HouseIcon, RankingIcon, ShieldIcon, TrophyIcon, UserCircleIcon } from "@phosphor-icons/react";
|
|
import { useMemo } from "react";
|
|
|
|
export const useLinks = (userId: string | undefined, roles: string[]) =>
|
|
useMemo(() => {
|
|
const links = [
|
|
{
|
|
label: 'Home',
|
|
href: '/',
|
|
Icon: HouseIcon
|
|
},
|
|
{
|
|
label: 'Statistics',
|
|
href: '/stats',
|
|
Icon: RankingIcon
|
|
},
|
|
{
|
|
label: 'Tournaments',
|
|
href: '/tournaments',
|
|
Icon: TrophyIcon,
|
|
exclude: ['/admin/tournaments']
|
|
},
|
|
{
|
|
label: 'Profile',
|
|
href: `/profile/${userId}`,
|
|
Icon: UserCircleIcon,
|
|
include: ['/settings']
|
|
}
|
|
]
|
|
|
|
if (roles.includes('Admin')) {
|
|
links.push({
|
|
label: 'Admin',
|
|
href: '/admin',
|
|
Icon: ShieldIcon
|
|
})
|
|
}
|
|
|
|
return links;
|
|
}, [userId, roles]); |