diff --git a/src/AppMenu.tsx b/src/AppMenu.tsx index 8592342..f633844 100644 --- a/src/AppMenu.tsx +++ b/src/AppMenu.tsx @@ -1,6 +1,8 @@ import React from "react"; import { Link } from "react-router-dom"; +import useCurrentUser from "./hooks/useCurrentUser"; + import playerSvg from "./assets/icons/player.svg"; import skull from "./assets/icons/skull.svg"; import sword from "./assets/icons/sword.svg"; @@ -12,30 +14,34 @@ interface GamesHQRouteOption { name: string; icon: string; to: string; + necessaryCapability: string; } export const AppMenu = ({ children }: { children: JSX.Element }) => { + const { currentUser } = useCurrentUser(); + const inspectRoutes = [ - { name: "Inspect Arena", to: "/inspect/arena", icon: playerSvg }, + { name: "Inspect Arena", to: "/inspect/arena", icon: playerSvg, necessaryCapability: "THE_ARENA_READ" }, ]; const databaseRoutes = [ /* { name: "Players", to: "/players", icon: playerSvg }, */ - { name: "Weapons", to: "/weapons", icon: sword }, + { name: "Weapons", to: "/weapons", icon: sword, necessaryCapability: "WEAPONS_READ" }, /* { name: "Traits", to: "/traits", icon: trait }, */ ]; const towerRoutes = [ - { name: "Tower Game", to: "/tower/status", icon: playerSvg }, - { name: "Enemies", to: "/enemies", icon: skull }, - { name: "Floors", to: "/floors", icon: floor }, + { name: "Tower Game", to: "/tower/status", icon: playerSvg, necessaryCapability: "THE_TOWER_READ" }, + { name: "Enemies", to: "/enemies", icon: skull, necessaryCapability: "ENEMY_READ" }, + { name: "Floors", to: "/floors", icon: floor, necessaryCapability: "THE_TOWER_READ" }, ]; - const arenaRoutes = [{ name: "Zones", to: "/zones", icon: zone }]; + const arenaRoutes = [{ name: "Zones", to: "/zones", icon: zone, necessaryCapability: "ZONE_READ" }]; - const gameDevRoutes = [{ name: "Games", to: "/games", icon: games }]; + const gameDevRoutes = [{ name: "Games", to: "/games", icon: games, necessaryCapability: "MY_GAME_READ" }]; const generateRouteList = (route: GamesHQRouteOption[]) => { - return route.map((route, i) => ( + + return route.map((route, i) => ( route.necessaryCapability && currentUser?.capabilities.includes(route.necessaryCapability) &&