diff --git a/resources/scripts/components/NavigationBar.tsx b/resources/scripts/components/NavigationBar.tsx index 19b9ed8ed..ac0d248fb 100644 --- a/resources/scripts/components/NavigationBar.tsx +++ b/resources/scripts/components/NavigationBar.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; -import { useState } from 'react'; -import { Link, NavLink } from 'react-router-dom'; +import { useState, useEffect } from 'react'; +import { Link, NavLink, useLocation } from 'react-router-dom'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faBars, faCogs, faLayerGroup, faSignOutAlt } from '@fortawesome/free-solid-svg-icons'; import { useStoreState } from 'easy-peasy'; @@ -38,14 +38,22 @@ const onTriggerNavButton = () => { if (sidebar) { sidebar.classList.toggle('active-nav'); } - - console.log('triggered'); }; export default () => { const name = useStoreState((state: ApplicationStore) => state.settings.data!.name); const rootAdmin = useStoreState((state: ApplicationStore) => state.user.data!.rootAdmin); const [isLoggingOut, setIsLoggingOut] = useState(false); + const location = useLocation(); + const [showSidebar, setShowSidebar] = useState(false); + + useEffect(() => { + if (location.pathname.startsWith('/server') || location.pathname.startsWith('/account')) { + setShowSidebar(true); + return; + } + setShowSidebar(false); + }, [location.pathname]); const onTriggerLogout = () => { setIsLoggingOut(true); @@ -59,7 +67,13 @@ export default () => {