Skip to content

Commit 86822f9

Browse files
committed
CORE-903: Go to Rex portal URL from portal Details page
[CORE-903]
1 parent 0aac1cf commit 86822f9

File tree

1 file changed

+11
-1
lines changed
  • src/app/pages/details/common/get-this-title-files

1 file changed

+11
-1
lines changed

src/app/pages/details/common/get-this-title-files/options.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import RecommendedCallout from './recommended-callout/recommended-callout';
1818
import {useOpenGiveDialog} from './give-before-pdf/use-give-dialog';
1919
import useCalloutCounter from './recommended-callout/use-callout-counter';
2020
import trackLink from '../track-link';
21+
import usePortalContext from '~/contexts/portal';
2122
import type {Model} from '../get-this-title';
2223
import type {TrackedMouseEvent} from '~/components/shell/router-helpers/use-link-handler';
2324

@@ -104,6 +105,15 @@ export function TocOption({model}: {model: Model}) {
104105
);
105106
}
106107

108+
function useRexPortalLinkOrNot(link: string) {
109+
const {portalPrefix} = usePortalContext();
110+
111+
if (!portalPrefix) {
112+
return link;
113+
}
114+
return link.replace('books/', `portal${portalPrefix}/books/`);
115+
}
116+
107117

108118
export function WebviewOption({model}: {model: Model}) {
109119
const [showCallout, hideForever] = useCalloutCounter(model.slug);
@@ -113,7 +123,7 @@ export function WebviewOption({model}: {model: Model}) {
113123
link: intl.formatMessage({id: 'getit.webview.link'})
114124
};
115125
const isRex = Boolean(model.webviewRexLink);
116-
const webviewLink = model.webviewRexLink || model.webviewLink;
126+
const webviewLink = useRexPortalLinkOrNot(model.webviewRexLink) || model.webviewLink;
117127
const iconAndTextArgs = {
118128
icon: faLaptop,
119129
text: $.isPolish(model.title) ? 'Zobacz w przeglądarce' : texts.link

0 commit comments

Comments
 (0)