- activities indexes + client_events/client_errors/rollups/alerts collections - global function middleware via createStart; reads skipped on success - actor stash, denial dedup, control-flow error guards - api route logging, auth event overrides, beacon endpoint, web vitals - centralized admin role checks, shared skeletons, award-badges fix - extracted deriveRunState with tests
45 lines
1.0 KiB
TypeScript
45 lines
1.0 KiB
TypeScript
import { HouseIcon, RankingIcon, ShieldIcon, TrophyIcon, UserCircleIcon } from "@phosphor-icons/react";
|
|
import { useMemo } from "react";
|
|
import { useLingui } from "@lingui/react/macro";
|
|
import { isAdminRole } from "../utils/roles";
|
|
|
|
export const useLinks = (userId: string | undefined, roles: string[]) => {
|
|
const { t } = useLingui();
|
|
|
|
return useMemo(() => {
|
|
const links = [
|
|
{
|
|
label: t`Home`,
|
|
href: '/',
|
|
Icon: HouseIcon
|
|
},
|
|
{
|
|
label: t`Statistics`,
|
|
href: '/stats',
|
|
Icon: RankingIcon
|
|
},
|
|
{
|
|
label: t`Tournaments`,
|
|
href: '/tournaments',
|
|
Icon: TrophyIcon,
|
|
exclude: ['/admin/tournaments']
|
|
},
|
|
{
|
|
label: t`Profile`,
|
|
href: `/profile/${userId}`,
|
|
Icon: UserCircleIcon,
|
|
include: ['/settings']
|
|
}
|
|
]
|
|
|
|
if (isAdminRole(roles)) {
|
|
links.push({
|
|
label: t`Admin`,
|
|
href: '/admin',
|
|
Icon: ShieldIcon
|
|
})
|
|
}
|
|
|
|
return links;
|
|
}, [userId, roles, t]);
|
|
}; |