1
1
import { useCallback } from 'react' ;
2
2
import { useNavigate , NavigateOptions } from 'react-router-dom' ;
3
- import usePortalContext from '~/contexts/portal' ;
4
3
import linkHelper from '~/helpers/link' ;
5
4
import $ from '~/helpers/$' ;
6
5
import retry from '~/helpers/retry' ;
@@ -11,12 +10,9 @@ export type TrackingInfo = {
11
10
book_format ?: string ;
12
11
contact_id ?: string ;
13
12
resource_name ?: string ;
14
- } ;
13
+ }
15
14
16
- export type TrackedMouseEvent = React . MouseEvent <
17
- HTMLAnchorElement ,
18
- MouseEvent
19
- > & {
15
+ export type TrackedMouseEvent = React . MouseEvent < HTMLAnchorElement , MouseEvent > & {
20
16
trackingInfo : TrackingInfo ;
21
17
} ;
22
18
@@ -36,18 +32,12 @@ function handleExternalLink(href: Location['href'], el: HTMLElement) {
36
32
type State = NavigateOptions & { x : number ; y : number } ;
37
33
38
34
export default function useLinkHandler ( ) {
39
- const { portal} = usePortalContext ( ) ;
40
35
const navigate = useNavigate ( ) ;
41
36
const navigateTo = useCallback (
42
37
( path : Location [ 'href' ] , state : State = { x : 0 , y : 0 } ) => {
43
- let adjustedPath = linkHelper . stripOpenStaxDomain ( path ) ;
44
-
45
- if ( portal && ! adjustedPath . startsWith ( `/${ portal } ` ) ) {
46
- adjustedPath = `/${ portal } ${ adjustedPath } ` ;
47
- }
48
- navigate ( adjustedPath , state ) ;
38
+ navigate ( linkHelper . stripOpenStaxDomain ( path ) , state ) ;
49
39
} ,
50
- [ navigate , portal ]
40
+ [ navigate ]
51
41
) ;
52
42
const linkHandler = useCallback (
53
43
// eslint-disable-next-line complexity
0 commit comments