File tree Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change
1
+ import usePortalContext from '~/contexts/portal' ;
2
+
3
+ export function useRexPortalLinkOrNot ( link : string ) {
4
+ const { portalPrefix} = usePortalContext ( ) ;
5
+
6
+ if ( ! portalPrefix ) {
7
+ return link ;
8
+ }
9
+ return link . replace ( 'books/' , `portal${ portalPrefix } /books/` ) ;
10
+ }
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import RecommendedCallout from './recommended-callout/recommended-callout';
18
18
import { useOpenGiveDialog } from './give-before-pdf/use-give-dialog' ;
19
19
import useCalloutCounter from './recommended-callout/use-callout-counter' ;
20
20
import trackLink from '../track-link' ;
21
+ import { useRexPortalLinkOrNot } from '~/helpers/rex-portal' ;
21
22
import type { Model } from '../get-this-title' ;
22
23
import type { TrackedMouseEvent } from '~/components/shell/router-helpers/use-link-handler' ;
23
24
@@ -104,7 +105,6 @@ export function TocOption({model}: {model: Model}) {
104
105
) ;
105
106
}
106
107
107
-
108
108
export function WebviewOption ( { model} : { model : Model } ) {
109
109
const [ showCallout , hideForever ] = useCalloutCounter ( model . slug ) ;
110
110
@@ -113,7 +113,7 @@ export function WebviewOption({model}: {model: Model}) {
113
113
link : intl . formatMessage ( { id : 'getit.webview.link' } )
114
114
} ;
115
115
const isRex = Boolean ( model . webviewRexLink ) ;
116
- const webviewLink = model . webviewRexLink || model . webviewLink ;
116
+ const webviewLink = useRexPortalLinkOrNot ( model . webviewRexLink ) || model . webviewLink ;
117
117
const iconAndTextArgs = {
118
118
icon : faLaptop ,
119
119
text : $ . isPolish ( model . title ) ? 'Zobacz w przeglądarce' : texts . link
Original file line number Diff line number Diff line change @@ -4,10 +4,11 @@ import partnerFeaturePromise from '~/models/salesforce-partners';
4
4
import shuffle from 'lodash/shuffle' ;
5
5
import { camelCaseKeys } from '~/helpers/page-data-utils' ;
6
6
import useDetailsContext from '../context' ;
7
+ import { useRexPortalLinkOrNot } from '~/helpers/rex-portal' ;
7
8
8
9
export function useTableOfContents ( ) {
9
10
const model = useDetailsContext ( ) ;
10
- const webviewLink = model . webviewRexLink ;
11
+ const webviewLink = useRexPortalLinkOrNot ( model . webviewRexLink ) ;
11
12
const [ tocHtml , setTocHtml ] = useState < string > ( '' ) ;
12
13
13
14
if ( webviewLink ) {
You can’t perform that action at this time.
0 commit comments