diff --git a/packages/client/src/modules/administration/Layout/Layout.tsx b/packages/client/src/modules/administration/Layout/Layout.tsx index 5bb9dbc9..50f7a18c 100644 --- a/packages/client/src/modules/administration/Layout/Layout.tsx +++ b/packages/client/src/modules/administration/Layout/Layout.tsx @@ -7,7 +7,7 @@ import ListSubheader from "@mui/material/ListSubheader"; import Typography from "@mui/material/Typography"; import Divider from "@mui/material/Divider"; import Container from "@mui/material/Container"; -import { Link, Navigate, Outlet, useMatch } from "react-router-dom"; +import { Link, Navigate, Outlet, PathMatch, useMatch } from "react-router-dom"; import GamesIcon from "@mui/icons-material/Games"; import PersonIcon from "@mui/icons-material/Person"; import SchoolIcon from "@mui/icons-material/School"; @@ -36,7 +36,13 @@ export { Layout }; function Layout() { const { permissions } = useAuth(); const theme = useTheme(); - const isGameAdministrationRoute = useMatch(`administration/games/:gameId/*`); + const routeMatch = useMatch(`administration/*`); + + const isNestedRoute = useMemo(() => { + return ( + routeMatch && routeMatch?.pathname.split("/").filter(Boolean).length > 2 + ); + }, [routeMatch]); if (!permissions.canAccessAdminPanel) { return ; @@ -50,7 +56,9 @@ function Layout() { pr: "24px", // keep right padding when drawer closed }} > - {isGameAdministrationRoute ? renderBackButton() : <>} + {isNestedRoute ? ( + + ) : null} -