1- import { Dispatch , FC , MutableRefObject , SetStateAction , useContext , useEffect , useRef , useState } from 'react'
1+ import {
2+ Dispatch ,
3+ FC ,
4+ MutableRefObject ,
5+ SetStateAction ,
6+ useContext ,
7+ useEffect ,
8+ useRef ,
9+ useState ,
10+ } from 'react'
211import classNames from 'classnames'
312
413import { EnvironmentConfig , PagePortalId } from '../config'
5- import { authUrlLogin , authUrlLogout , authUrlSignup , profileContext , ProfileContextData } from '../lib'
14+ import {
15+ authUrlLogin ,
16+ authUrlLogout ,
17+ authUrlSignup ,
18+ profileContext ,
19+ ProfileContextData ,
20+ routeContext ,
21+ RouteContextData ,
22+ } from '../lib'
623
724import UniNavSnippet from './universal-nav-snippet'
825
@@ -11,6 +28,7 @@ declare let tcUniNav: any
1128
1229const Header : FC = ( ) => {
1330
31+ const { activeToolName } : RouteContextData = useContext ( routeContext )
1432 const { profile, initialized : profileReady } : ProfileContextData = useContext ( profileContext )
1533 const [ ready , setReady ] : [ boolean , Dispatch < SetStateAction < boolean > > ] = useState < boolean > ( false )
1634 const headerInit : MutableRefObject < boolean > = useRef ( false )
@@ -37,8 +55,7 @@ const Header: FC = () => {
3755 signIn ( ) { window . location . href = authUrlLogin ( ) } ,
3856 signOut ( ) { window . location . href = authUrlLogout } ,
3957 signUp ( ) { window . location . href = authUrlSignup ( ) } ,
40- // TODO: make this dynamic based on the current URL
41- toolName : 'Topcoder Academy' ,
58+ toolName : activeToolName ,
4259 user : profileReady && profile ? {
4360 handle : profile . handle ,
4461 initials : `${ profile . firstName . charAt ( 0 ) } ${ profile . lastName . charAt ( 0 ) } ` ,
@@ -47,7 +64,10 @@ const Header: FC = () => {
4764 } : undefined ,
4865 } ,
4966 )
50- } , [ profileReady , profile ] )
67+ } , [
68+ activeToolName ,
69+ profileReady ,
70+ profile ] )
5171
5272 return (
5373 < >
0 commit comments