Skip to content

Commit ab1d866

Browse files
committed
Add offer description and viewerUrl
1 parent 96f2f93 commit ab1d866

File tree

12 files changed

+51
-12
lines changed

12 files changed

+51
-12
lines changed

lib/config-defaults.ts

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ export const coreUrl = 'https://squid-api.tjek.com';
22
export const coreUrlStaging = 'https://squid-api.tjek-staging.com';
33
export const eventsTrackUrl = 'https://wolf-api.tjek.com/sync';
44
export const eventsTrackUrlStaging = 'https://wolf-api.tjek-staging.com/sync';
5+
export const viewerUrl = 'https://publication-viewer.tjek.com';
6+
export const viewerUrlStaging = 'https://publication-viewer.tjek-staging.com';

lib/config.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ import MicroEvent from '../vendor/microevent';
22
import * as configDefaults from './config-defaults';
33

44
class Config extends MicroEvent<{change: [Record<string, any>]}> {
5-
keys = ['apiKey', 'eventTracker', 'coreUrl', 'eventsTrackUrl'] as const;
5+
keys = [
6+
'apiKey',
7+
'eventTracker',
8+
'coreUrl',
9+
'eventsTrackUrl',
10+
'viewerUrl'
11+
] as const;
612
_attrs = {...configDefaults};
713

814
set(config: Record<string, any>) {

lib/kits/core-ui/list-publications.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ const ListPublications = (
2121
mainContainer = '',
2222
apiKey,
2323
coreUrl,
24-
eventTracker
24+
eventTracker,
25+
viewerUrl
2526
}: {
2627
mainContainer: string;
2728
apiKey: string;
2829
coreUrl: string;
2930
eventTracker: Tracker;
31+
viewerUrl: string | undefined;
3032
}
3133
) => {
3234
const scriptEls = {
@@ -112,7 +114,8 @@ const ListPublications = (
112114
mainContainer: '#sgn-publication-viewer-container',
113115
apiKey,
114116
coreUrl,
115-
eventTracker
117+
eventTracker,
118+
viewerUrl
116119
});
117120

118121
pagedPublication.setOptions({id});

lib/kits/core-ui/paged-publication.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ const PagedPublication = (
3030
mainContainer = '',
3131
apiKey,
3232
coreUrl,
33-
eventTracker
33+
eventTracker,
34+
viewerUrl
3435
}: {
3536
mainContainer: string;
3637
apiKey: string;
3738
coreUrl: string;
3839
eventTracker: Tracker;
40+
viewerUrl: string | undefined;
3941
}
4042
) => {
4143
let options;
@@ -161,6 +163,7 @@ const PagedPublication = (
161163
el: document.querySelector<HTMLDivElement>('.sgn__pp'),
162164
apiKey,
163165
coreUrl,
166+
viewerUrl,
164167
eventTracker,
165168
pageId:
166169
opts?.pageId ||

lib/kits/paged-publication/bootstrapper.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ interface BootstrapperInit {
99
eventTracker: Tracker;
1010
apiKey: string;
1111
coreUrl: string;
12+
viewerUrl: string | undefined;
1213
keyboard: 'disabled' | 'enabled' | 'global';
1314
}
1415
export default class Bootstrapper {
@@ -174,11 +175,15 @@ export default class Bootstrapper {
174175
}
175176

176177
fetchPageHotspotsAndDecorations = (pageId: number) => {
177-
return request({
178-
apiKey: this.options.apiKey,
179-
coreUrl: 'https://publication-viewer.tjek.com/',
180-
url: `/api/paged-publications/${this.options.id}/${pageId}`
181-
});
178+
if (this.options.viewerUrl) {
179+
return request({
180+
apiKey: this.options.apiKey,
181+
coreUrl: this.options.viewerUrl,
182+
url: `/api/paged-publications/${this.options.id}/${pageId}`
183+
});
184+
}
185+
186+
return false;
182187

183188
// this.applyHotspots(hotspots);
184189
};

lib/kits/paged-publication/hotspots.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,21 @@ function renderHotspot(hotspot, position, contentRect, boundingRect) {
9999

100100
if (hotspot.type === 'offer') {
101101
const translations = {
102-
for: translate('publication_viewer_offer_price_for')
102+
for: translate('publication_viewer_offer_price_for'),
103+
description: translate('publication_viewer_offer_description')
103104
};
104105
const pieceCountFor =
105106
hotspot.offer.quantity.pieces.from > 1
106107
? `${hotspot.offer.quantity.pieces.from} ${translations.for} `
107108
: '';
109+
const description = hotspot.offer.description
110+
? `${translations.description}${hotspot.offer.description}`
111+
: '';
108112

109113
el.setAttribute('tabindex', '-1');
110114
el.setAttribute(
111115
'aria-label',
112-
`${hotspot.offer.heading}; ${pieceCountFor}${hotspot.offer.pricing.price} ${hotspot.offer.pricing.currency};`
116+
`${hotspot.offer.heading}; ${pieceCountFor}${hotspot.offer.pricing.price} ${hotspot.offer.pricing.currency}; ${description};`
113117
);
114118

115119
const observer = new IntersectionObserver((entries) => {

lib/kits/paged-publication/viewer.ts

+6
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export interface V3Hotspot {
5353
| {
5454
id: string;
5555
name: string;
56+
description: string | undefined;
5657
}
5758
| undefined;
5859
rotate: number | undefined;
@@ -507,6 +508,7 @@ class Viewer extends MicroEvent {
507508
id: hotspot.offer?.id || '',
508509
ern: '',
509510
heading: hotspot.offer?.name || '',
511+
description: hotspot.offer?.description || '',
510512
pricing: {
511513
currency: '',
512514
price: 0
@@ -543,6 +545,10 @@ class Viewer extends MicroEvent {
543545
pageNumber
544546
);
545547

548+
if (!hotspots) {
549+
return;
550+
}
551+
546552
const transformedHotspots = this.transformPageHotspotsAndDecorations(
547553
hotspots,
548554
pageNumber

lib/sgn-sdk.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ import {
1717
import * as clientLocal from './storage/client-local';
1818
import './stylus/sgn.styl';
1919
import {error, isBrowser} from './util';
20-
import {coreUrlStaging, eventsTrackUrlStaging} from './config-defaults';
20+
import {
21+
coreUrlStaging,
22+
eventsTrackUrlStaging,
23+
viewerUrlStaging
24+
} from './config-defaults';
2125

2226
export const config = new Config();
2327
config.bind('change', (changedAttributes) => {
@@ -61,6 +65,7 @@ if (isBrowser()) {
6165
apiKey?: string;
6266
eventTracker?: Tracker;
6367
coreUrl?: string;
68+
viewerUrl?: string;
6469
} = {};
6570

6671
if (apiKey) {
@@ -69,6 +74,7 @@ if (isBrowser()) {
6974

7075
if (isStaging) {
7176
scriptConfig.coreUrl = coreUrlStaging;
77+
scriptConfig.viewerUrl = viewerUrlStaging;
7278
}
7379

7480
if (trackId) {

locales/da_DK.ts

+1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ export default {
2424
publication_viewer_offer_price_from: 'Fra',
2525
publication_viewer_offer_price_for: 'for',
2626
publication_viewer_offer_valid_from: 'Gælder kun fra d. ',
27+
publication_viewer_offer_description: 'Beskrivelse ',
2728
publication_viewer_no_product_message: 'Ingen produkt detaljer'
2829
};

locales/en_US.ts

+1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ export default {
2424
publication_viewer_offer_price_from: 'From',
2525
publication_viewer_offer_price_for: 'for',
2626
publication_viewer_offer_valid_from: 'Valid from ',
27+
publication_viewer_offer_description: 'Description ',
2728
publication_viewer_no_product_message: 'No product details'
2829
};

locales/nb_NO.ts

+1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ export default {
2525
publication_viewer_offer_price_from: 'Fra',
2626
publication_viewer_offer_price_for: 'for',
2727
publication_viewer_offer_valid_from: 'Gjelder kun fra ',
28+
publication_viewer_offer_description: 'Beskrivelse ',
2829
publication_viewer_no_product_message: 'Ingen produktdetalje'
2930
};

locales/sv_SE.ts

+1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ export default {
2424
publication_viewer_offer_price_from: 'Från',
2525
publication_viewer_offer_price_for: 'för',
2626
publication_viewer_offer_valid_from: 'Gäller endast fr.o.m ',
27+
publication_viewer_offer_description: 'Beskrivning ',
2728
publication_viewer_no_product_message: 'Inga produktdetaljer'
2829
};

0 commit comments

Comments
 (0)