@@ -5,12 +5,11 @@ import React, { useState, useCallback, useMemo, useEffect } from "react";
5
5
import _ from "lodash" ;
6
6
import MainMenu from "./components/MainMenu" ;
7
7
import NavBar from "./components/NavBar" ;
8
- import { matchPath , Router , useLocation } from "@reach/router" ;
8
+ import { navigate , Router , useLocation } from "@reach/router" ;
9
9
import { useSelector } from "react-redux" ;
10
10
import useMatchSomeRoute from "./hooks/useMatchSomeRoute" ;
11
11
import NotificationsModal from "./components/NotificationsModal" ;
12
12
import "./styles/main.module.scss" ;
13
- import { checkOnboardingPath } from "./utils" ;
14
13
15
14
const App = ( ) => {
16
15
// all menu options
@@ -19,14 +18,18 @@ const App = () => {
19
18
const apps = useMemo ( ( ) => _ . flatMap ( menu , "apps" ) , [ menu ] ) ;
20
19
// list of routes where we have to disabled sidebar
21
20
const disabledRoutes = useSelector ( ( state ) => state . menu . disabledRoutes ) ;
21
+ // list of routes where we have to disabled navigations
22
+ const disabledNavigations = useSelector (
23
+ ( state ) => state . menu . disabledNavigations
24
+ ) ;
22
25
// user profile information
23
26
const auth = useSelector ( ( state ) => state . auth ) ;
24
27
// `true` is sidebar has to be disabled for the current route
25
28
const isSideBarDisabled = useMatchSomeRoute ( disabledRoutes ) ;
29
+ // `true` is navigation has to be disabled for the current route
30
+ const isNavigationDisabled = useMatchSomeRoute ( disabledNavigations ) ;
26
31
// Left sidebar collapse state
27
32
const [ sidebarCollapsed , setSidebarCollapsed ] = useState ( false ) ;
28
- // hide switch tools and notification when user is onboarding
29
- const [ hideSwitchTools , setHideSwitchTools ] = useState ( false ) ;
30
33
// Toggle left sidebar callback
31
34
const toggleSidebar = useCallback ( ( ) => {
32
35
setSidebarCollapsed ( ! sidebarCollapsed ) ;
@@ -47,19 +50,11 @@ const App = () => {
47
50
} else {
48
51
document . body . classList . remove ( "no-sidebar" ) ;
49
52
}
50
- } , [ isSideBarDisabled ] ) ;
51
-
52
- useEffect ( ( ) => {
53
- if ( matchPath ( "onboard/*" , location . pathname ) ) {
54
- setHideSwitchTools ( true ) ;
55
- } else {
56
- setHideSwitchTools ( false ) ;
57
- }
58
- } , [ location ] ) ;
53
+ } , [ isSideBarDisabled , location . pathname ] ) ;
59
54
60
55
return (
61
56
< >
62
- < NavBar hideSwitchTools = { hideSwitchTools } />
57
+ < NavBar hideSwitchTools = { isNavigationDisabled } />
63
58
{ ! isSideBarDisabled && (
64
59
< div className = "main-menu-wrapper" >
65
60
< Router >
0 commit comments