@@ -2,8 +2,13 @@ import classNames from 'classnames'
2
2
import { FC , useContext } from 'react'
3
3
import { Link , useLocation } from 'react-router-dom'
4
4
5
- import { ToolTitle } from '../../../../config'
6
- import { PlatformRoute , routeContext , RouteContextData , routeIsActive , routeIsHome } from '../../../../lib'
5
+ import {
6
+ PlatformRoute ,
7
+ routeContext ,
8
+ RouteContextData ,
9
+ routeIsActive ,
10
+ routeIsHome ,
11
+ } from '../../../../lib'
7
12
import '../../../../lib/styles/index.scss'
8
13
9
14
import styles from './ToolSelectorWide.module.scss'
@@ -14,15 +19,17 @@ interface ToolSelectorWideProps {
14
19
15
20
const ToolSelectorWide : FC < ToolSelectorWideProps > = ( props : ToolSelectorWideProps ) => {
16
21
17
- const { getPath, getPathFromRoute } : RouteContextData = useContext ( routeContext )
18
- const currentPath : string = useLocation ( ) . pathname
22
+ const { getPathFromRoute } : RouteContextData = useContext ( routeContext )
23
+ const activePath : string = useLocation ( ) . pathname
24
+ const toolRoute : PlatformRoute = props . route
25
+ const toolPath : string = getPathFromRoute ( toolRoute )
26
+
27
+ const isActive : boolean = routeIsActive ( activePath , toolPath )
19
28
20
- // for now, the work tool should be active for all pages except the account
21
- const isActive : boolean = ! routeIsActive ( currentPath , getPath ( ToolTitle . settings ) )
22
29
const activeIndicatorClass : string = `tool-selector-wide-${ isActive ? '' : 'in' } active`
23
30
24
31
// the tool link should be usable for all active routes except the home page
25
- const isLink : boolean = isActive && ! routeIsHome ( currentPath )
32
+ const isLink : boolean = isActive && ! routeIsHome ( activePath )
26
33
27
34
return (
28
35
< div className = { classNames (
@@ -33,9 +40,9 @@ const ToolSelectorWide: FC<ToolSelectorWideProps> = (props: ToolSelectorWideProp
33
40
< Link
34
41
className = 'large-tab'
35
42
tabIndex = { - 1 }
36
- to = { getPathFromRoute ( props . route ) }
43
+ to = { toolPath }
37
44
>
38
- { props . route . title }
45
+ { toolRoute . title }
39
46
</ Link >
40
47
< div className = { styles [ 'active-indicator' ] } > </ div >
41
48
</ div >
0 commit comments