import React from 'react'; import { NavLink, Route, Switch, useRouteMatch } from 'react-router-dom'; import TransitionRouter from '@/TransitionRouter'; import PermissionRoute from '@/components/elements/PermissionRoute'; import Can from '@/components/elements/Can'; import Spinner from '@/components/elements/Spinner'; import { NotFound } from '@/components/elements/ScreenBlock'; import { useLocation } from 'react-router'; import routes from '@/routers/routes'; import blueprintRoutes from './routes'; export const NavigationLinks = () => { const match = useRouteMatch<{ id: string }>(); const to = (value: string, url = false) => { if (value === '/') { return url ? match.url : match.path; } return `${(url ? match.url : match.path).replace(/\/*$/, '')}/${value.replace(/^\/+/, '')}`; }; return ( <> {/* Pterodactyl routes */} {routes.server .filter((route) => !!route.name) .map((route) => route.permission ? ( {route.name} ) : ( {route.name} ) )} {/* Blueprint routes */} {blueprintRoutes.server.length > 0 && blueprintRoutes.server .filter((route) => !!route.name) .map((route) => route.permission ? ( {route.name} ) : ( {route.name} ) )} ); }; export const NavigationRouter = () => { const match = useRouteMatch<{ id: string }>(); const to = (value: string, url = false) => { if (value === '/') { return url ? match.url : match.path; } return `${(url ? match.url : match.path).replace(/\/*$/, '')}/${value.replace(/^\/+/, '')}`; }; const location = useLocation(); return ( <> {/* Pterodactyl routes */} {routes.server.map(({ path, permission, component: Component }) => ( ))} {/* Blueprint routes */} {blueprintRoutes.server.length > 0 && blueprintRoutes.server.map(({ path, permission, component: Component }) => ( ))} ); };