@@ -30,6 +30,11 @@ import UniNavSnippet from './universal-nav-snippet'
30
30
declare let tcUniNav : any
31
31
UniNavSnippet ( EnvironmentConfig . UNIVERSAL_NAV . URL )
32
32
33
+ interface NavigationRequest {
34
+ label : string
35
+ path : string
36
+ }
37
+
33
38
const Header : FC = ( ) => {
34
39
35
40
const { activeToolName, activeToolRoute } : RouteContextData = useContext ( routeContext )
@@ -39,16 +44,12 @@ const Header: FC = () => {
39
44
const navElementId : string = 'main-nav-el'
40
45
const navigate : NavigateFunction = useNavigate ( )
41
46
42
- console . debug ( 'active route' , activeToolRoute )
43
-
44
- const navigationHandler : ( label : string , path : string ) => void
45
- = useCallback ( ( label : string , path : string ) => {
46
-
47
- console . debug ( path )
47
+ const navigationHandler : ( request : NavigationRequest ) => void
48
+ = useCallback ( ( request : NavigationRequest ) => {
48
49
49
50
try {
50
51
// strip the domain and navigate to the path
51
- navigate ( new URL ( path ) . pathname )
52
+ navigate ( new URL ( request . path ) . pathname )
52
53
} catch ( error ) {
53
54
// if we couldn't navigate to the path, just go to the route of the currently active tool
54
55
navigate ( new URL ( activeToolRoute || '/' ) . pathname )
@@ -71,7 +72,7 @@ const Header: FC = () => {
71
72
'init' ,
72
73
navElementId ,
73
74
{
74
- navigationHandler,
75
+ handleNavigation : navigationHandler ,
75
76
onReady ( ) {
76
77
setReady ( true )
77
78
document . getElementById ( 'root' ) ?. classList . add ( 'app-ready' )
@@ -80,7 +81,7 @@ const Header: FC = () => {
80
81
signOut ( ) { window . location . href = authUrlLogout } ,
81
82
signUp ( ) { window . location . href = authUrlSignup ( ) } ,
82
83
toolName : activeToolName ,
83
- toolRoute : activeToolRoute ,
84
+ toolRoot : activeToolRoute ,
84
85
type : 'tool' ,
85
86
user : profile ? {
86
87
handle : profile . handle ,
0 commit comments