gatsby-core-theme 41.1.6 → 41.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/gatsby-node.mjs +16 -54
- package/package.json +1 -1
- package/src/components/atoms/admin/bar/layout-section/index.js +1 -1
- package/src/components/molecules/header/variants/slot/template-one/index.js +2 -3
- package/src/components/molecules/header/variants/slot/template-one/templateone.test.js +1 -1
- package/src/constants/pick-keys.mjs +3 -3
- package/src/helpers/api.mjs +8 -20
- package/src/helpers/fetch-site-settings.mjs +25 -6
- package/src/helpers/getters.mjs +1 -1
- package/src/helpers/getters.test.js +1 -1
- package/src/helpers/processor/games.mjs +64 -0
- package/src/helpers/processor/index.mjs +2 -6
- package/src/helpers/processor/modules.mjs +3 -21
- package/src/helpers/processor/relations.mjs +5 -20
- package/src/helpers/server-data.js +9 -37
- package/src/components/pages/tracker-geo/index-ssr.js +0 -196
- package/src/components/pages/tracker-geo/index.js +0 -196
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## [41.1.8](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v41.1.7...v41.1.8) (2024-12-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* game relation ([1ee1976](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/1ee19762c03dd3c3a75ca68842b04590d84a3ef4))
|
|
7
|
+
|
|
8
|
+
## [41.1.7](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v41.1.6...v41.1.7) (2024-12-11)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* v2 apis and preview feature ([f526fa6](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/f526fa67ec08a3b4b4878d31ff4a9dbf18eee130))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
* Merge branch 'tm-4960-5005-4906-v2-feature' into 'master' ([5af777e](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/5af777e45613060efed2534fe1f4db9a32e25ccc))
|
|
17
|
+
|
|
1
18
|
## [41.1.6](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v41.1.5...v41.1.6) (2024-12-09)
|
|
2
19
|
|
|
3
20
|
|
package/gatsby-node.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import chalk from "chalk";
|
|
|
10
10
|
import fs from "fs";
|
|
11
11
|
import { dirname } from "path";
|
|
12
12
|
import { fileURLToPath } from "url";
|
|
13
|
-
import {
|
|
13
|
+
import { getTranslations } from "./src/helpers/api.mjs";
|
|
14
14
|
import { fetchSiteSettings } from "./src/helpers/fetch-site-settings.mjs";
|
|
15
15
|
import { generateTrackerLink } from "./src/helpers/generators.mjs";
|
|
16
16
|
import processor, {
|
|
@@ -30,7 +30,6 @@ let prefilledModules = [];
|
|
|
30
30
|
let operators = null;
|
|
31
31
|
|
|
32
32
|
let context404 = null;
|
|
33
|
-
let sports = null;
|
|
34
33
|
let siteSchema = null;
|
|
35
34
|
let authors = null;
|
|
36
35
|
|
|
@@ -42,6 +41,9 @@ let translationsData = null;
|
|
|
42
41
|
let siteSettingsData = null;
|
|
43
42
|
let siteGeneralData = null;
|
|
44
43
|
let allMarketsData = null;
|
|
44
|
+
let providersData = null;
|
|
45
|
+
let gamesData = null;
|
|
46
|
+
let sportsData = null;
|
|
45
47
|
let ribbonsData = null;
|
|
46
48
|
let operatorData = null;
|
|
47
49
|
let paymentData = null;
|
|
@@ -199,19 +201,6 @@ export const createPages = async (
|
|
|
199
201
|
) => {
|
|
200
202
|
process.env.GATSBY_SITE_NAME = String(themeOptions.siteName);
|
|
201
203
|
|
|
202
|
-
let response = [];
|
|
203
|
-
if (process.env.LOCAL_DATA === "false") {
|
|
204
|
-
console.log(
|
|
205
|
-
chalk.magenta("info") + chalk.whiteBright(" getting data from api")
|
|
206
|
-
);
|
|
207
|
-
response = await getData(String(themeOptions.siteName));
|
|
208
|
-
} else {
|
|
209
|
-
console.log(
|
|
210
|
-
chalk.magenta("info") + chalk.whiteBright(" getting data from local file")
|
|
211
|
-
);
|
|
212
|
-
response = await getLocalData(fs);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
204
|
const stream = fs.createWriteStream("rewrites.conf");
|
|
216
205
|
console.log(
|
|
217
206
|
chalk.magenta("info") + chalk.whiteBright(" creating rewrite rules")
|
|
@@ -249,34 +238,9 @@ export const createPages = async (
|
|
|
249
238
|
preconnectLinks = themeOptions.preconnectLinks || [];
|
|
250
239
|
console.log(chalk.magenta("info") + chalk.whiteBright(" starting processor"));
|
|
251
240
|
|
|
252
|
-
delete response.site_markets;
|
|
253
|
-
delete response.pages;
|
|
254
|
-
delete response.redirects;
|
|
255
|
-
delete response.breadcrumbs;
|
|
256
|
-
delete response.general;
|
|
257
|
-
delete response.schema;
|
|
258
|
-
delete response.menus;
|
|
259
|
-
delete response.page_styles;
|
|
260
|
-
delete response.categories;
|
|
261
|
-
delete response.ribbons;
|
|
262
|
-
delete response.prefilled_market_modules;
|
|
263
|
-
delete response.templates;
|
|
264
|
-
delete response.authors;
|
|
265
|
-
delete response.relations.translations;
|
|
266
|
-
delete response.relations.responsible_gamings;
|
|
267
|
-
delete response.relations.dms_affiliate_settings;
|
|
268
|
-
delete response.relations.operator;
|
|
269
|
-
delete response.relations.payment_method;
|
|
270
|
-
|
|
271
|
-
// Note: Not used
|
|
272
|
-
delete response.colors;
|
|
273
|
-
delete response.module_styles;
|
|
274
|
-
delete response.styles;
|
|
275
|
-
|
|
276
241
|
// add data to modules
|
|
277
242
|
const processed = processor.run(
|
|
278
243
|
{
|
|
279
|
-
...response,
|
|
280
244
|
...siteSettingsData,
|
|
281
245
|
pages: pagesData,
|
|
282
246
|
general: siteGeneralData,
|
|
@@ -286,9 +250,11 @@ export const createPages = async (
|
|
|
286
250
|
content: contentData,
|
|
287
251
|
ribbons: ribbonsData,
|
|
288
252
|
relations: {
|
|
289
|
-
...response.relations,
|
|
290
253
|
operator: operatorData,
|
|
291
254
|
payment_method: paymentData,
|
|
255
|
+
software_provider: providersData,
|
|
256
|
+
game: gamesData,
|
|
257
|
+
sports_data: sportsData
|
|
292
258
|
},
|
|
293
259
|
},
|
|
294
260
|
themeOptions,
|
|
@@ -302,12 +268,6 @@ export const createPages = async (
|
|
|
302
268
|
|
|
303
269
|
htmlSitemapPages = processSitemapPages(pages, processed.site_markets);
|
|
304
270
|
|
|
305
|
-
if (["rage_seo", "rage_ppc", "sports"].includes(siteGeneralData.type)) {
|
|
306
|
-
sports = Object.keys(response.relations["sports_data"].sports).map(
|
|
307
|
-
(key) => response.relations["sports_data"].sports[key]
|
|
308
|
-
);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
271
|
// create robots.txt file
|
|
312
272
|
const robotsTxtContent = siteGeneralData.robots_txt
|
|
313
273
|
? siteGeneralData.robots_txt
|
|
@@ -334,7 +294,7 @@ export const createPages = async (
|
|
|
334
294
|
processedPage.preconnect_links = preconnectLinks;
|
|
335
295
|
|
|
336
296
|
siteSchema = schemaData[page["market_id"]];
|
|
337
|
-
authors =
|
|
297
|
+
authors = siteSettingsData.authors;
|
|
338
298
|
|
|
339
299
|
// siteInfo, siteSchema and authors are added to page for schemaGenerator()
|
|
340
300
|
page.siteInfo = siteGeneralData;
|
|
@@ -416,12 +376,11 @@ export const createPages = async (
|
|
|
416
376
|
const pageTemplate = "tracker";
|
|
417
377
|
if (["rage_seo", "rage_ppc"].includes(siteGeneralData.type)) {
|
|
418
378
|
Object.keys(
|
|
419
|
-
(
|
|
420
|
-
|
|
421
|
-
processed.relations.sports_data.providers) ||
|
|
379
|
+
( sportsData &&
|
|
380
|
+
sportsData.providers) ||
|
|
422
381
|
{}
|
|
423
382
|
).forEach((providerId) => {
|
|
424
|
-
const provider =
|
|
383
|
+
const provider = sportsData.providers[providerId];
|
|
425
384
|
const tracker = generateTrackerLink(provider, "main", true, pageTemplate);
|
|
426
385
|
const trackerPageObject = {
|
|
427
386
|
meta_title: "Tracker",
|
|
@@ -563,7 +522,10 @@ export const onPreBootstrap = async () => {
|
|
|
563
522
|
contentData,
|
|
564
523
|
pagesData,
|
|
565
524
|
operatorData,
|
|
566
|
-
paymentData
|
|
525
|
+
paymentData,
|
|
526
|
+
providersData,
|
|
527
|
+
gamesData,
|
|
528
|
+
sportsData
|
|
567
529
|
} = await fetchSiteSettings(process.env.GATSBY_SITE_NAME));
|
|
568
530
|
};
|
|
569
531
|
|
|
@@ -593,7 +555,7 @@ export const sourceNodes = async ({
|
|
|
593
555
|
const translation = {
|
|
594
556
|
key: key[0],
|
|
595
557
|
value: key[1],
|
|
596
|
-
language
|
|
558
|
+
language,
|
|
597
559
|
};
|
|
598
560
|
|
|
599
561
|
const nodeMeta = {
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@ const LayoutSection = ({ menus }) => {
|
|
|
13
13
|
case "operator":
|
|
14
14
|
return `operators/${id.operator_id}/sites-data/edit/${id.id}`;
|
|
15
15
|
case "game":
|
|
16
|
-
return `games/${id.
|
|
16
|
+
return `games/${id.game_id}/sites?site_name=${process.env.GATSBY_SITE_NAME}`;
|
|
17
17
|
case "author":
|
|
18
18
|
return `site-authors/${id}`;
|
|
19
19
|
case "payment_method":
|
|
@@ -17,8 +17,7 @@ export default function SlotHeader({
|
|
|
17
17
|
width = '170',
|
|
18
18
|
height = '170',
|
|
19
19
|
}) {
|
|
20
|
-
const imageObject =
|
|
21
|
-
page.relation?.standardised_logo_filename_object || page.relation?.thumbnail_filename_object;
|
|
20
|
+
const imageObject = page.relation?.logo;
|
|
22
21
|
|
|
23
22
|
const averageRating = page.relation?.average_rating;
|
|
24
23
|
// eslint-disable-next-line react/prop-types
|
|
@@ -84,7 +83,7 @@ SlotHeader.propTypes = {
|
|
|
84
83
|
volatility: PropTypes.number,
|
|
85
84
|
average_rating: PropTypes.string,
|
|
86
85
|
thumbnail_filename_object: PropTypes.string,
|
|
87
|
-
|
|
86
|
+
logo: PropTypes.shape({}),
|
|
88
87
|
slot: PropTypes.shape({
|
|
89
88
|
name: PropTypes.string,
|
|
90
89
|
game_provider: PropTypes.string,
|
|
@@ -56,7 +56,7 @@ describe('summary component', () => {
|
|
|
56
56
|
await waitFor(() => expect(img).toBeVisible());
|
|
57
57
|
expect(img).toHaveAttribute(
|
|
58
58
|
'src',
|
|
59
|
-
imagePrettyUrl(page.relation?.
|
|
59
|
+
imagePrettyUrl(page.relation?.logo?.filename, 170, 170)
|
|
60
60
|
);
|
|
61
61
|
expect(img).toHaveAttribute('width', '170');
|
|
62
62
|
expect(img).toHaveAttribute('height', '170');
|
|
@@ -112,14 +112,13 @@ export const pickRelationKeys = {
|
|
|
112
112
|
],
|
|
113
113
|
game: [
|
|
114
114
|
"id",
|
|
115
|
+
"game_id",
|
|
115
116
|
"game_provider",
|
|
117
|
+
"provider_path",
|
|
116
118
|
"first_rating",
|
|
117
119
|
"second_rating",
|
|
118
120
|
"third_rating",
|
|
119
121
|
"fourth_rating",
|
|
120
|
-
"standardised_logo_filename_object",
|
|
121
|
-
"thumbnail_filename",
|
|
122
|
-
"thumbnail_filename_object",
|
|
123
122
|
"name",
|
|
124
123
|
"iframe",
|
|
125
124
|
"average_rating",
|
|
@@ -133,6 +132,7 @@ export const pickRelationKeys = {
|
|
|
133
132
|
"minimum_bet",
|
|
134
133
|
"jackpots",
|
|
135
134
|
"launch_date",
|
|
135
|
+
"logo"
|
|
136
136
|
],
|
|
137
137
|
software_provider: [
|
|
138
138
|
"logo_filename_object",
|
package/src/helpers/api.mjs
CHANGED
|
@@ -106,13 +106,14 @@ export async function getProviders() {
|
|
|
106
106
|
return callAPIV2(`v0.1/globals/software-sorted-v2`);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
export async function
|
|
109
|
+
export async function getGames(params) {
|
|
110
|
+
return callAPIV2(`v0.1/games/games-sorted-v2${params ? `?${params}` : ''}`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// TO MODIFY and use the new sports API
|
|
114
|
+
export async function getSportsData(siteName) {
|
|
110
115
|
let path = `${API_URL}/sites/v0.1/pages/sorted?site_name=${siteName}`;
|
|
111
116
|
|
|
112
|
-
if (page) {
|
|
113
|
-
path += `&path=${page}`;
|
|
114
|
-
if(preview) path +=`&market_id=${marketId}&preview=1`
|
|
115
|
-
}
|
|
116
117
|
path += '&reverse_order=1&relations=1';
|
|
117
118
|
console.log(chalk.magenta('calling ') + chalk.whiteBright(path));
|
|
118
119
|
|
|
@@ -123,23 +124,10 @@ export async function getData(siteName, page = null, marketId = null, preview =
|
|
|
123
124
|
.then((response) => {
|
|
124
125
|
const end = new Date() - start;
|
|
125
126
|
console.log(chalk.green('success') + chalk.whiteBright(` calling hercules - %ds`), end / 1000);
|
|
126
|
-
resolve(response.data.result);
|
|
127
|
+
resolve(response.data.result.relations.sports_data);
|
|
127
128
|
})
|
|
128
129
|
.catch((error) => {
|
|
129
130
|
reject(error.response.data.errors.join());
|
|
130
131
|
});
|
|
131
132
|
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export async function getLocalData(fs) {
|
|
135
|
-
return new Promise((resolve, reject) => {
|
|
136
|
-
if (!fs.existsSync('./src/data/source/data.json')) {
|
|
137
|
-
reject(new Error('Local Data file not found!'));
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
let response = fs.readFileSync('./src/data/source/data.json');
|
|
141
|
-
response = JSON.parse(response);
|
|
142
|
-
resolve(response.result);
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
|
|
133
|
+
}
|
|
@@ -7,16 +7,19 @@ import {
|
|
|
7
7
|
getToplists,
|
|
8
8
|
getPages,
|
|
9
9
|
getOperators,
|
|
10
|
+
getGames,
|
|
10
11
|
getCountries,
|
|
11
12
|
getCurrencies,
|
|
12
13
|
getPayments,
|
|
13
|
-
getProviders
|
|
14
|
+
getProviders,
|
|
15
|
+
getSportsData
|
|
14
16
|
} from "./api.mjs";
|
|
15
17
|
import { transformOperators } from "./processor/operators.mjs";
|
|
18
|
+
import { transformGames } from "./processor/games.mjs";
|
|
16
19
|
import { transformPayments } from "./processor/payment.mjs";
|
|
17
20
|
import { transformProvider } from "./processor/providers.mjs";
|
|
18
21
|
|
|
19
|
-
export const fetchSiteSettings = async (siteName
|
|
22
|
+
export const fetchSiteSettings = async (siteName) => {
|
|
20
23
|
const siteSettingsPromise = getSiteSettings(siteName);
|
|
21
24
|
const ribbonsPromise = getRibbons(`site=${process.env.GATSBY_SITE_NAME}`);
|
|
22
25
|
|
|
@@ -37,12 +40,15 @@ export const fetchSiteSettings = async (siteName, isPreview) => {
|
|
|
37
40
|
const operatorPromise = getOperators(
|
|
38
41
|
`site_name=${process.env.GATSBY_SITE_NAME}`
|
|
39
42
|
);
|
|
43
|
+
const gamesPromise = getGames(`site_name=${process.env.GATSBY_SITE_NAME}`);
|
|
40
44
|
|
|
41
45
|
const paymentPromise = getPayments(Object.keys(allMarketsData));
|
|
42
46
|
|
|
43
47
|
const contentPromise = getContent(process.env.GATSBY_SITE_NAME);
|
|
44
48
|
const pagesPromise = getPages(process.env.GATSBY_SITE_NAME);
|
|
45
49
|
|
|
50
|
+
|
|
51
|
+
|
|
46
52
|
const [
|
|
47
53
|
ribbonsData,
|
|
48
54
|
responsableGamingData,
|
|
@@ -53,7 +59,8 @@ export const fetchSiteSettings = async (siteName, isPreview) => {
|
|
|
53
59
|
countriesData,
|
|
54
60
|
currenciesData,
|
|
55
61
|
payments,
|
|
56
|
-
providers
|
|
62
|
+
providers,
|
|
63
|
+
games
|
|
57
64
|
] = await Promise.all([
|
|
58
65
|
ribbonsPromise,
|
|
59
66
|
responsableGamingPromise,
|
|
@@ -64,7 +71,8 @@ export const fetchSiteSettings = async (siteName, isPreview) => {
|
|
|
64
71
|
countriesPromise,
|
|
65
72
|
currenciesPromise,
|
|
66
73
|
paymentPromise,
|
|
67
|
-
providersPromise
|
|
74
|
+
providersPromise,
|
|
75
|
+
gamesPromise
|
|
68
76
|
]);
|
|
69
77
|
|
|
70
78
|
const allMarketPrefixes = Object.keys(allMarketsData)
|
|
@@ -84,9 +92,18 @@ export const fetchSiteSettings = async (siteName, isPreview) => {
|
|
|
84
92
|
ribbons: ribbonsData,
|
|
85
93
|
countries: countriesData,
|
|
86
94
|
currencies: currenciesData,
|
|
87
|
-
providers: providersData
|
|
95
|
+
providers: providersData,
|
|
88
96
|
});
|
|
89
97
|
|
|
98
|
+
const gamesData = transformGames(games, {
|
|
99
|
+
providers: providersData,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
let sportsData = null;
|
|
103
|
+
if(["rage_seo", "rage_ppc", "sports"].includes(siteSettingsData.general[siteId].type)) {
|
|
104
|
+
sportsData = await getSportsData(process.env.GATSBY_SITE_NAME);
|
|
105
|
+
}
|
|
106
|
+
|
|
90
107
|
return {
|
|
91
108
|
siteSettingsData,
|
|
92
109
|
siteGeneralData: siteSettingsData.general[siteId],
|
|
@@ -104,6 +121,8 @@ export const fetchSiteSettings = async (siteName, isPreview) => {
|
|
|
104
121
|
countriesData,
|
|
105
122
|
currenciesData,
|
|
106
123
|
paymentData,
|
|
107
|
-
providersData
|
|
124
|
+
providersData,
|
|
125
|
+
gamesData,
|
|
126
|
+
sportsData
|
|
108
127
|
};
|
|
109
128
|
};
|
package/src/helpers/getters.mjs
CHANGED
|
@@ -188,7 +188,7 @@ export function getPageImage(page) {
|
|
|
188
188
|
page.relation &&
|
|
189
189
|
page.relation.logo
|
|
190
190
|
) {
|
|
191
|
-
return page.relation && imagePrettyUrl(page.relation.logo);
|
|
191
|
+
return page.relation && imagePrettyUrl(page.relation.logo.filename);
|
|
192
192
|
}
|
|
193
193
|
if (page.banner) {
|
|
194
194
|
return imagePrettyUrl(page.banner);
|
|
@@ -129,7 +129,7 @@ describe('Getters Helper', () => {
|
|
|
129
129
|
Getters.imagePrettyUrl('bar.svg')
|
|
130
130
|
);
|
|
131
131
|
expect(
|
|
132
|
-
Getters.getPageImage({ relation_type: 'software_provider', relation: { logo: 'logo.jpg' } })
|
|
132
|
+
Getters.getPageImage({ relation_type: 'software_provider', relation: { logo: {filename: 'logo.jpg'}, } })
|
|
133
133
|
).toEqual(Getters.imagePrettyUrl('logo.jpg'));
|
|
134
134
|
expect(Getters.getPageImage({ banner: 'bar.svg' })).toEqual(Getters.imagePrettyUrl('bar.svg'));
|
|
135
135
|
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
+
import loadash from "lodash/index.js";
|
|
3
|
+
import { filterNonNullValues } from "gatsby-core-theme/src/helpers/getters.mjs";
|
|
4
|
+
import { pickRelationKeys } from "../../constants/pick-keys.mjs";
|
|
5
|
+
import { getProviderData } from "./providers.mjs";
|
|
6
|
+
|
|
7
|
+
const { cloneDeep, pick } = loadash;
|
|
8
|
+
|
|
9
|
+
export function sanitizegameData(game, pages = null) {
|
|
10
|
+
const gameClone = cloneDeep(game);
|
|
11
|
+
|
|
12
|
+
const providerPage = pages
|
|
13
|
+
? pages.filter((provider) => game.game_provider?.id === provider.relation_id)
|
|
14
|
+
: null;
|
|
15
|
+
|
|
16
|
+
if(providerPage && providerPage.length > 0 && gameClone.game_provider) {
|
|
17
|
+
gameClone.game_provider.path = providerPage[0].path;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return pick(gameClone, pickRelationKeys.game);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function transformGames(jsonData, relationsData) {
|
|
24
|
+
const games = {};
|
|
25
|
+
|
|
26
|
+
// Iterate over each operator
|
|
27
|
+
Object.entries(jsonData).forEach(([shortname, gamesData]) => {
|
|
28
|
+
const {
|
|
29
|
+
general_data: generalData = {},
|
|
30
|
+
sites_data: sitesData = {},
|
|
31
|
+
markets_data: marketsData = {},
|
|
32
|
+
} = gamesData;
|
|
33
|
+
|
|
34
|
+
// Iterate over each market in sites_data
|
|
35
|
+
Object.entries(sitesData).forEach(([market, sitesMarketData]) => {
|
|
36
|
+
const filteredSitesData = filterNonNullValues(sitesMarketData);
|
|
37
|
+
const marketSpecificData = filterNonNullValues(
|
|
38
|
+
marketsData ? marketsData[market] || {} : {}
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
// Combining all general, market and sites Data
|
|
42
|
+
const newGamesData = {
|
|
43
|
+
...generalData, // General data
|
|
44
|
+
...marketSpecificData, // Filtered market-specific data
|
|
45
|
+
...filteredSitesData, // Filtered affiliate data
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
newGamesData.logo = newGamesData.logo || newGamesData.standardised_logo;
|
|
49
|
+
|
|
50
|
+
// Provider
|
|
51
|
+
newGamesData.game_provider = relationsData.providers[
|
|
52
|
+
newGamesData.game_provider_id
|
|
53
|
+
]
|
|
54
|
+
? getProviderData(
|
|
55
|
+
relationsData.providers[newGamesData.game_provider_id]
|
|
56
|
+
)
|
|
57
|
+
: null;
|
|
58
|
+
|
|
59
|
+
games[sitesMarketData.id] = sanitizegameData(newGamesData);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return games;
|
|
64
|
+
}
|
|
@@ -141,7 +141,6 @@ export function processSections(
|
|
|
141
141
|
markets,
|
|
142
142
|
siteName,
|
|
143
143
|
data,
|
|
144
|
-
isPreview,
|
|
145
144
|
toplists,
|
|
146
145
|
content
|
|
147
146
|
) {
|
|
@@ -196,7 +195,6 @@ export function processSections(
|
|
|
196
195
|
{ ...relationData, siteName, pageTitle: page?.title },
|
|
197
196
|
markets,
|
|
198
197
|
data,
|
|
199
|
-
isPreview,
|
|
200
198
|
toplists,
|
|
201
199
|
content
|
|
202
200
|
);
|
|
@@ -323,7 +321,7 @@ function updatePlaceholders(page, data, translationsData) {
|
|
|
323
321
|
}
|
|
324
322
|
|
|
325
323
|
export default {
|
|
326
|
-
run(data, themeOptions, fs, translationsData,
|
|
324
|
+
run(data, themeOptions, fs, translationsData, previewPagePath = null) {
|
|
327
325
|
const start = new Date();
|
|
328
326
|
const transformedPages = transform(data);
|
|
329
327
|
|
|
@@ -567,7 +565,6 @@ export default {
|
|
|
567
565
|
data.site_markets,
|
|
568
566
|
generalData.site_name,
|
|
569
567
|
null,
|
|
570
|
-
isPreview,
|
|
571
568
|
data.toplists,
|
|
572
569
|
data.content
|
|
573
570
|
);
|
|
@@ -579,7 +576,7 @@ export default {
|
|
|
579
576
|
transformedPages[market][pageType].forEach((page, index) => {
|
|
580
577
|
page.hreflangs = generateHreflangs(page, data);
|
|
581
578
|
|
|
582
|
-
if (page.sections) {
|
|
579
|
+
if ((page.sections && !previewPagePath) || (previewPagePath && page.path === previewPagePath)) {
|
|
583
580
|
transformedPages[market][pageType][index] = Object.assign(page, {
|
|
584
581
|
sections: processSections(
|
|
585
582
|
page.sections,
|
|
@@ -589,7 +586,6 @@ export default {
|
|
|
589
586
|
data.site_markets,
|
|
590
587
|
generalData.site_name,
|
|
591
588
|
data,
|
|
592
|
-
isPreview,
|
|
593
589
|
data.toplists,
|
|
594
590
|
data.content
|
|
595
591
|
),
|
|
@@ -115,8 +115,7 @@ export function processCardsV2(
|
|
|
115
115
|
module,
|
|
116
116
|
pagesCloned,
|
|
117
117
|
pagesMappedById,
|
|
118
|
-
pageId
|
|
119
|
-
isPreview
|
|
118
|
+
pageId
|
|
120
119
|
) {
|
|
121
120
|
const cardType = module.cards_page_type;
|
|
122
121
|
const pageTemplateId = module.cards_page_type_id;
|
|
@@ -151,23 +150,7 @@ export function processCardsV2(
|
|
|
151
150
|
const selectedReviewer = module.cards_selector_filters.page_reviewer;
|
|
152
151
|
const selectedCategories = module.cards_selector_filters.page_categories;
|
|
153
152
|
|
|
154
|
-
const
|
|
155
|
-
cardType,
|
|
156
|
-
pageTemplateId,
|
|
157
|
-
selectedAuthors,
|
|
158
|
-
selectedReviewer,
|
|
159
|
-
selectedCategories,
|
|
160
|
-
moduleSelectedProviders,
|
|
161
|
-
moduleSelectedCategories,
|
|
162
|
-
moduleSelectedTypes,
|
|
163
|
-
];
|
|
164
|
-
const u8 = new Uint8Array(allFilters);
|
|
165
|
-
let b64 = "";
|
|
166
|
-
if (!isPreview) {
|
|
167
|
-
b64 = Buffer.from(u8).toString("base64");
|
|
168
|
-
} else {
|
|
169
|
-
b64 = (Math.random() + 1).toString(36).substring(7);
|
|
170
|
-
}
|
|
153
|
+
const b64 = (Math.random() + 1).toString(36).substring(7);
|
|
171
154
|
|
|
172
155
|
if (cardType) {
|
|
173
156
|
// Get all pages by the selected page type
|
|
@@ -438,7 +421,6 @@ export function processModule(
|
|
|
438
421
|
relationData,
|
|
439
422
|
markets,
|
|
440
423
|
data,
|
|
441
|
-
isPreview,
|
|
442
424
|
toplists,
|
|
443
425
|
content
|
|
444
426
|
) {
|
|
@@ -461,7 +443,7 @@ export function processModule(
|
|
|
461
443
|
}
|
|
462
444
|
|
|
463
445
|
if (module.name === "cards_v2") {
|
|
464
|
-
processCardsV2(module, pagesCloned, pagesMappedById, pageId
|
|
446
|
+
processCardsV2(module, pagesCloned, pagesMappedById, pageId);
|
|
465
447
|
} else if (module.name === "content") {
|
|
466
448
|
processContentModule(module, translations, relationData, content);
|
|
467
449
|
} else if (module.name === "bonus") {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
2
|
import loadash from "lodash/index.js";
|
|
3
|
-
import { mergeMarketValues } from "./game.mjs";
|
|
4
3
|
import { pickRelationKeys } from "../../constants/pick-keys.mjs";
|
|
4
|
+
import { sanitizegameData } from "./games.mjs"
|
|
5
5
|
import { getPaymentDataByMarket } from "./payment.mjs";
|
|
6
6
|
import { getProviderData } from "./providers.mjs";
|
|
7
7
|
|
|
@@ -15,8 +15,7 @@ export const processRelations = (
|
|
|
15
15
|
market,
|
|
16
16
|
data,
|
|
17
17
|
index,
|
|
18
|
-
isPreview
|
|
19
|
-
translations
|
|
18
|
+
isPreview
|
|
20
19
|
) => {
|
|
21
20
|
if (page.relation_type !== "page" && page.relation_id) {
|
|
22
21
|
const hasRelation =
|
|
@@ -29,24 +28,10 @@ export const processRelations = (
|
|
|
29
28
|
: null;
|
|
30
29
|
|
|
31
30
|
switch (page.relation_type) {
|
|
32
|
-
// Add path for game page from game provider
|
|
31
|
+
// // Add path for game page from game provider
|
|
33
32
|
case "game":
|
|
34
|
-
if (hasRelation && transformedPages[market][pageType][index].relation) {
|
|
35
|
-
|
|
36
|
-
transformedPages[market][pageType][index].relation.game_provider.id;
|
|
37
|
-
const providerPage = transformedPages[market].software_provider
|
|
38
|
-
? transformedPages[market].software_provider.filter(
|
|
39
|
-
(provider) => providerId === provider.relation_id
|
|
40
|
-
)
|
|
41
|
-
: [];
|
|
42
|
-
transformedPages[market][pageType][
|
|
43
|
-
index
|
|
44
|
-
].relation.game_provider.path =
|
|
45
|
-
providerPage.length > 0 ? providerPage[0].path : null;
|
|
46
|
-
page.relation = pick(
|
|
47
|
-
mergeMarketValues(page.relation, market),
|
|
48
|
-
pickRelationKeys.game
|
|
49
|
-
);
|
|
33
|
+
if (hasRelation && transformedPages[market][pageType][index].relation) {
|
|
34
|
+
page.relation = sanitizegameData(page.relation, transformedPages[market].software_provider)
|
|
50
35
|
}
|
|
51
36
|
break;
|
|
52
37
|
// Add author for page from authors
|
|
@@ -6,7 +6,6 @@ import chalk from 'chalk';
|
|
|
6
6
|
import loadSource from "~helpers/search-source";
|
|
7
7
|
import { deparam } from "~helpers/strings";
|
|
8
8
|
import { groupBy } from "~helpers/getters";
|
|
9
|
-
import { getData } from "~helpers/api";
|
|
10
9
|
import processor from "./processor/index.mjs";
|
|
11
10
|
import { fetchSiteSettings } from "./fetch-site-settings.mjs";
|
|
12
11
|
|
|
@@ -15,37 +14,6 @@ export async function getAPIData(page, url, headers, preview) {
|
|
|
15
14
|
const start = new Date();
|
|
16
15
|
const siteName = process.env.GATSBY_SITE_NAME;
|
|
17
16
|
const params = deparam(url.split("?")[1]);
|
|
18
|
-
// eslint-disable-next-line camelcase
|
|
19
|
-
const response = await getData(
|
|
20
|
-
siteName,
|
|
21
|
-
params?.path,
|
|
22
|
-
params?.market_id,
|
|
23
|
-
true
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
delete response.site_markets;
|
|
27
|
-
delete response.pages;
|
|
28
|
-
delete response.redirects;
|
|
29
|
-
delete response.breadcrumbs;
|
|
30
|
-
delete response.general;
|
|
31
|
-
delete response.schema;
|
|
32
|
-
delete response.menus;
|
|
33
|
-
delete response.page_styles;
|
|
34
|
-
delete response.categories;
|
|
35
|
-
delete response.ribbons;
|
|
36
|
-
delete response.prefilled_market_modules;
|
|
37
|
-
delete response.templates;
|
|
38
|
-
delete response.authors;
|
|
39
|
-
delete response.relations.translations;
|
|
40
|
-
delete response.relations.responsible_gamings;
|
|
41
|
-
delete response.relations.dms_affiliate_settings;
|
|
42
|
-
delete response.relations.operator;
|
|
43
|
-
delete response.relations.payment_method;
|
|
44
|
-
|
|
45
|
-
// Note: Not used
|
|
46
|
-
delete response.colors;
|
|
47
|
-
delete response.module_styles;
|
|
48
|
-
delete response.styles;
|
|
49
17
|
|
|
50
18
|
const {
|
|
51
19
|
siteSettingsData,
|
|
@@ -57,12 +25,15 @@ export async function getAPIData(page, url, headers, preview) {
|
|
|
57
25
|
pagesData,
|
|
58
26
|
operatorData,
|
|
59
27
|
paymentData,
|
|
60
|
-
allMarketsData
|
|
28
|
+
allMarketsData,
|
|
29
|
+
gamesData,
|
|
30
|
+
providersData
|
|
61
31
|
} = await fetchSiteSettings(siteName, true);
|
|
62
32
|
|
|
33
|
+
const pagePath = `${params?.market && allMarketsData[params?.market].path_prefix ? `${allMarketsData[params?.market].path_prefix}/` : '' }${params?.path}`
|
|
34
|
+
|
|
63
35
|
const processed = processor.run(
|
|
64
36
|
{
|
|
65
|
-
...response,
|
|
66
37
|
...siteSettingsData,
|
|
67
38
|
pages: pagesData,
|
|
68
39
|
general: siteGeneralData,
|
|
@@ -72,19 +43,20 @@ export async function getAPIData(page, url, headers, preview) {
|
|
|
72
43
|
content: contentData,
|
|
73
44
|
ribbons: ribbonsData,
|
|
74
45
|
relations: {
|
|
75
|
-
...response.relations,
|
|
76
46
|
operator: operatorData,
|
|
77
47
|
payment_method: paymentData,
|
|
48
|
+
software_provider: providersData,
|
|
49
|
+
game: gamesData
|
|
78
50
|
},
|
|
79
51
|
},
|
|
80
52
|
{},
|
|
81
53
|
null,
|
|
82
54
|
null,
|
|
83
|
-
|
|
55
|
+
pagePath
|
|
84
56
|
);
|
|
85
57
|
|
|
86
58
|
const pagePreviewProcessed = Object.values(pagesData).filter(
|
|
87
|
-
(value) => (value.path ===
|
|
59
|
+
(value) => (value.path === pagePath)
|
|
88
60
|
);
|
|
89
61
|
|
|
90
62
|
if(pagePreviewProcessed.length > 0 ) {
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
/* eslint-disable react/prop-types */
|
|
3
|
-
/* eslint-disable react/forbid-prop-types */
|
|
4
|
-
import React, { useEffect } from 'react';
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
6
|
-
import LazyImage from '~hooks/lazy-image';
|
|
7
|
-
import { imagePrettyUrl, getAltText } from '~helpers/getters';
|
|
8
|
-
import { getTrackerName, getAffiliateLink } from '~helpers/tracker';
|
|
9
|
-
import styles from './tracker.module.scss';
|
|
10
|
-
import HeadData from '~organisms/head';
|
|
11
|
-
import Logo from '~images/icons/logo';
|
|
12
|
-
|
|
13
|
-
export default function TrackerGeo({
|
|
14
|
-
pageContext,
|
|
15
|
-
path,
|
|
16
|
-
mainText = 'One sec, while we load [operator_name] for you..',
|
|
17
|
-
redirectText = 'If the casino has not loaded within a few seconds',
|
|
18
|
-
bgImage = '',
|
|
19
|
-
bgVideo = '',
|
|
20
|
-
redirectTimer = 5000,
|
|
21
|
-
logo = <Logo />,
|
|
22
|
-
counter = false,
|
|
23
|
-
operatorLogo = false,
|
|
24
|
-
operatorLogoWidth = 80,
|
|
25
|
-
operatorLogoHeight = 80,
|
|
26
|
-
siteLogoWidth = '100',
|
|
27
|
-
siteLogoHeight = '100',
|
|
28
|
-
serverData,
|
|
29
|
-
}) {
|
|
30
|
-
const { page, operatorsByMarket } = pageContext;
|
|
31
|
-
const operator = operatorsByMarket[Object.keys(operatorsByMarket)[0]][0];
|
|
32
|
-
// eslint-disable-next-line dot-notation
|
|
33
|
-
const defaultMarketOperator = operatorsByMarket[`us_en`] || null;
|
|
34
|
-
const showSplashScreen = typeof window !== 'undefined';
|
|
35
|
-
|
|
36
|
-
const getData = async () => {
|
|
37
|
-
if (serverData.success && serverData.result.link) {
|
|
38
|
-
console.log('FROM API');
|
|
39
|
-
window.location.replace(serverData.result.link);
|
|
40
|
-
} else {
|
|
41
|
-
console.log('FROM LOCAL');
|
|
42
|
-
await fetch('https://geolocation-db.com/json/', {
|
|
43
|
-
method: 'GET',
|
|
44
|
-
})
|
|
45
|
-
.then((response) => response.json())
|
|
46
|
-
.then(async (data) => {
|
|
47
|
-
const ipAddress = data.IPv4;
|
|
48
|
-
const apiUrl = `https://pro.ip-api.com/json/${ipAddress}?key=sQhiSjgnSScSHqR&fields=status,countryCode,region,city,zip,lat,lon`;
|
|
49
|
-
|
|
50
|
-
await fetch(apiUrl, {})
|
|
51
|
-
.then((response) => response.json())
|
|
52
|
-
.then((data1) => {
|
|
53
|
-
if (data1.countryCode) {
|
|
54
|
-
const userMarketOperator =
|
|
55
|
-
operatorsByMarket[`us_en_${data1.region.toLowerCase()}`] || null;
|
|
56
|
-
|
|
57
|
-
const trackerRedirect =
|
|
58
|
-
(userMarketOperator && userMarketOperator[0]) || defaultMarketOperator[0];
|
|
59
|
-
|
|
60
|
-
if (trackerRedirect) {
|
|
61
|
-
setTimeout(
|
|
62
|
-
() => window.location.replace(getTrackerName(trackerRedirect, page, path)),
|
|
63
|
-
redirectTimer
|
|
64
|
-
);
|
|
65
|
-
} else {
|
|
66
|
-
console.log('No Valid Tracker');
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
})
|
|
70
|
-
.catch((err) => {
|
|
71
|
-
console.log(`Error ${err}`);
|
|
72
|
-
setTimeout(
|
|
73
|
-
() => window.location.replace(getTrackerName(defaultMarketOperator[0], page, path)),
|
|
74
|
-
redirectTimer
|
|
75
|
-
);
|
|
76
|
-
});
|
|
77
|
-
})
|
|
78
|
-
.catch((err) => {
|
|
79
|
-
console.log(`Error ${err}`);
|
|
80
|
-
setTimeout(
|
|
81
|
-
() => window.location.replace(getTrackerName(defaultMarketOperator[0], page, path)),
|
|
82
|
-
redirectTimer
|
|
83
|
-
);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
window.loadGTM = false;
|
|
90
|
-
getData();
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
let background = <></>;
|
|
94
|
-
if (bgVideo) {
|
|
95
|
-
background = (
|
|
96
|
-
<video muted autoPlay loop className={styles.background} poster={bgImage && bgImage}>
|
|
97
|
-
<source src={bgVideo} type="video/webm" />
|
|
98
|
-
</video>
|
|
99
|
-
);
|
|
100
|
-
} else if (bgImage) {
|
|
101
|
-
background = <LazyImage className={styles.background} src={bgImage} alt="background image" />;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return (
|
|
105
|
-
<>
|
|
106
|
-
{showSplashScreen && (
|
|
107
|
-
<>
|
|
108
|
-
<div className={styles.container}>
|
|
109
|
-
{background}
|
|
110
|
-
<div className={styles.content}>
|
|
111
|
-
<LazyImage alt="Site logo" src={logo} width={siteLogoWidth} height={siteLogoHeight} />
|
|
112
|
-
<p
|
|
113
|
-
className={`${styles.mainText} ${operatorLogo && styles.mainTextWithlogo}`}
|
|
114
|
-
>{`${mainText.replace(
|
|
115
|
-
'[operator_name]',
|
|
116
|
-
operator?.bonus?.operator_name || operator.name
|
|
117
|
-
)}`}</p>
|
|
118
|
-
{operatorLogo && (
|
|
119
|
-
<LazyImage
|
|
120
|
-
src={imagePrettyUrl(
|
|
121
|
-
operator?.logo?.filename,
|
|
122
|
-
operatorLogoWidth,
|
|
123
|
-
operatorLogoHeight
|
|
124
|
-
)}
|
|
125
|
-
alt={getAltText(operator?.logo, operator.name)}
|
|
126
|
-
loading="eager"
|
|
127
|
-
width={operatorLogoWidth}
|
|
128
|
-
height={operatorLogoHeight}
|
|
129
|
-
className={styles.operatorlogo}
|
|
130
|
-
/>
|
|
131
|
-
)}
|
|
132
|
-
<div className={styles.bar} />
|
|
133
|
-
{counter ? (
|
|
134
|
-
redirectText
|
|
135
|
-
) : (
|
|
136
|
-
<div
|
|
137
|
-
className={styles.redirectText}
|
|
138
|
-
// eslint-disable-next-line react/no-danger
|
|
139
|
-
dangerouslySetInnerHTML={{ __html: redirectText }}
|
|
140
|
-
/>
|
|
141
|
-
)}
|
|
142
|
-
</div>
|
|
143
|
-
</div>
|
|
144
|
-
</>
|
|
145
|
-
)}
|
|
146
|
-
</>
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export const Head = ({ pageContext }) => (
|
|
151
|
-
<HeadData page={pageContext.page} siteInfo={pageContext.siteInfo} />
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
TrackerGeo.propTypes = {
|
|
155
|
-
redirectText: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
156
|
-
mainText: PropTypes.string,
|
|
157
|
-
bgImage: PropTypes.string,
|
|
158
|
-
bgVideo: PropTypes.string,
|
|
159
|
-
path: PropTypes.string,
|
|
160
|
-
logo: PropTypes.element,
|
|
161
|
-
counter: PropTypes.bool,
|
|
162
|
-
redirectTimer: PropTypes.number,
|
|
163
|
-
operatorLogo: PropTypes.bool,
|
|
164
|
-
operatorLogoWidth: PropTypes.string,
|
|
165
|
-
operatorLogoHeight: PropTypes.string,
|
|
166
|
-
pageContext: PropTypes.shape({
|
|
167
|
-
operatorsByMarket: PropTypes.shape({
|
|
168
|
-
bonus: PropTypes.shape({
|
|
169
|
-
operator_name: PropTypes.string,
|
|
170
|
-
}),
|
|
171
|
-
name: PropTypes.string,
|
|
172
|
-
logo: PropTypes.shape({}),
|
|
173
|
-
links: PropTypes.shape({
|
|
174
|
-
main: PropTypes.string,
|
|
175
|
-
terms_and_conditions: PropTypes.string,
|
|
176
|
-
}),
|
|
177
|
-
}).isRequired,
|
|
178
|
-
page: PropTypes.shape({
|
|
179
|
-
template: PropTypes.string,
|
|
180
|
-
}),
|
|
181
|
-
}),
|
|
182
|
-
styles: PropTypes.shape({}),
|
|
183
|
-
serverData: PropTypes.any,
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
export async function getServerData({ pageContext, headers, url }) {
|
|
187
|
-
let res = '';
|
|
188
|
-
res = await getAffiliateLink(
|
|
189
|
-
pageContext.operator,
|
|
190
|
-
pageContext.page.path,
|
|
191
|
-
pageContext.page,
|
|
192
|
-
headers,
|
|
193
|
-
url
|
|
194
|
-
);
|
|
195
|
-
return res;
|
|
196
|
-
}
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
/* eslint-disable react/prop-types */
|
|
3
|
-
/* eslint-disable react/forbid-prop-types */
|
|
4
|
-
import React, { useEffect } from 'react';
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
6
|
-
import LazyImage from '~hooks/lazy-image';
|
|
7
|
-
import { imagePrettyUrl, getAltText } from '~helpers/getters';
|
|
8
|
-
import { generateTrackerLink } from '~helpers/generators';
|
|
9
|
-
import styles from './tracker.module.scss';
|
|
10
|
-
import HeadData from '~organisms/head';
|
|
11
|
-
|
|
12
|
-
export default function TrackerGeo({
|
|
13
|
-
pageContext,
|
|
14
|
-
path,
|
|
15
|
-
mainText = 'One sec, while we load [operator_name] for you..',
|
|
16
|
-
redirectText = 'If the casino has not loaded within a few seconds',
|
|
17
|
-
bgImage = '',
|
|
18
|
-
bgVideo = '',
|
|
19
|
-
redirectTimer = 5000,
|
|
20
|
-
logo = '/images/logo.svg',
|
|
21
|
-
counter = false,
|
|
22
|
-
operatorLogo = false,
|
|
23
|
-
operatorLogoWidth = 80,
|
|
24
|
-
operatorLogoHeight = 80,
|
|
25
|
-
siteLogoWidth = '100',
|
|
26
|
-
siteLogoHeight = '100',
|
|
27
|
-
}) {
|
|
28
|
-
const { page, operatorsByMarket } = pageContext;
|
|
29
|
-
const operator = operatorsByMarket[Object.keys(operatorsByMarket)[0]][0];
|
|
30
|
-
// eslint-disable-next-line dot-notation
|
|
31
|
-
const defaultMarketOperator = operatorsByMarket[`us_en`] || null;
|
|
32
|
-
const showSplashScreen = typeof window !== 'undefined';
|
|
33
|
-
|
|
34
|
-
// eslint-disable-next-line no-shadow
|
|
35
|
-
const getTracker = (operator) => {
|
|
36
|
-
let tracker = '';
|
|
37
|
-
const trackerLinks = operator ? Object.keys(operator.links) : [];
|
|
38
|
-
for (let i = 0; i < trackerLinks.length; i += 1) {
|
|
39
|
-
const trackerLink = trackerLinks[i].toLowerCase().replace(' ', '_');
|
|
40
|
-
if (generateTrackerLink(operator, trackerLink, false, page.template) === path) {
|
|
41
|
-
tracker =
|
|
42
|
-
operator.links[
|
|
43
|
-
Object.keys(operator.links).find(
|
|
44
|
-
(key) => key.toLowerCase() === trackerLink.toLowerCase()
|
|
45
|
-
)
|
|
46
|
-
];
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
tracker = operator.links.main;
|
|
51
|
-
}
|
|
52
|
-
return tracker;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const getData = async () => {
|
|
56
|
-
await fetch('https://geolocation-db.com/json/', {
|
|
57
|
-
method: 'GET',
|
|
58
|
-
})
|
|
59
|
-
.then((response) => response.json())
|
|
60
|
-
.then(async (data) => {
|
|
61
|
-
const ipAddress = data.IPv4;
|
|
62
|
-
const apiUrl = `https://pro.ip-api.com/json/${ipAddress}?key=sQhiSjgnSScSHqR&fields=status,countryCode,region,city,zip,lat,lon`;
|
|
63
|
-
|
|
64
|
-
await fetch(apiUrl, {})
|
|
65
|
-
.then((response) => response.json())
|
|
66
|
-
.then((data1) => {
|
|
67
|
-
if (data1.countryCode) {
|
|
68
|
-
const userMarketOperator =
|
|
69
|
-
operatorsByMarket[`us_en_${data1.region.toLowerCase()}`] || null;
|
|
70
|
-
|
|
71
|
-
const trackerRedirect =
|
|
72
|
-
(userMarketOperator && userMarketOperator[0]) || defaultMarketOperator[0];
|
|
73
|
-
|
|
74
|
-
if (trackerRedirect) {
|
|
75
|
-
setTimeout(
|
|
76
|
-
() => window.location.replace(getTracker(trackerRedirect)),
|
|
77
|
-
redirectTimer
|
|
78
|
-
);
|
|
79
|
-
} else {
|
|
80
|
-
console.log('No Valid Tracker');
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
})
|
|
84
|
-
.catch((err) => {
|
|
85
|
-
console.log(`Error ${err}`);
|
|
86
|
-
setTimeout(
|
|
87
|
-
() => window.location.replace(getTracker(defaultMarketOperator[0])),
|
|
88
|
-
redirectTimer
|
|
89
|
-
);
|
|
90
|
-
});
|
|
91
|
-
})
|
|
92
|
-
.catch((err) => {
|
|
93
|
-
console.log(`Error ${err}`);
|
|
94
|
-
setTimeout(
|
|
95
|
-
() => window.location.replace(getTracker(defaultMarketOperator[0])),
|
|
96
|
-
redirectTimer
|
|
97
|
-
);
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
useEffect(() => {
|
|
102
|
-
window.loadGTM = false;
|
|
103
|
-
getData();
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
let background = <></>;
|
|
107
|
-
if (bgVideo) {
|
|
108
|
-
background = (
|
|
109
|
-
<video muted autoPlay loop className={styles.background} poster={bgImage && bgImage}>
|
|
110
|
-
<source src={bgVideo} type="video/webm" />
|
|
111
|
-
</video>
|
|
112
|
-
);
|
|
113
|
-
} else if (bgImage) {
|
|
114
|
-
background = <LazyImage className={styles.background} src={bgImage} alt="background image" />;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return (
|
|
118
|
-
<>
|
|
119
|
-
{showSplashScreen && (
|
|
120
|
-
<>
|
|
121
|
-
<div className={styles.container}>
|
|
122
|
-
{background}
|
|
123
|
-
<div className={styles.content}>
|
|
124
|
-
<LazyImage alt="Site logo" src={logo} width={siteLogoWidth} height={siteLogoHeight} />
|
|
125
|
-
<p
|
|
126
|
-
className={`${styles.mainText} ${operatorLogo && styles.mainTextWithlogo}`}
|
|
127
|
-
>{`${mainText.replace(
|
|
128
|
-
'[operator_name]',
|
|
129
|
-
operator?.bonus?.operator_name || operator.name
|
|
130
|
-
)}`}</p>
|
|
131
|
-
{operatorLogo && (
|
|
132
|
-
<LazyImage
|
|
133
|
-
src={imagePrettyUrl(
|
|
134
|
-
operator?.logo?.filename,
|
|
135
|
-
operatorLogoWidth,
|
|
136
|
-
operatorLogoHeight
|
|
137
|
-
)}
|
|
138
|
-
alt={getAltText(operator?.logo, operator.name)}
|
|
139
|
-
loading="eager"
|
|
140
|
-
width={operatorLogoWidth}
|
|
141
|
-
height={operatorLogoHeight}
|
|
142
|
-
className={styles.operatorlogo}
|
|
143
|
-
/>
|
|
144
|
-
)}
|
|
145
|
-
<div className={styles.bar} />
|
|
146
|
-
{counter ? (
|
|
147
|
-
redirectText
|
|
148
|
-
) : (
|
|
149
|
-
<div
|
|
150
|
-
className={styles.redirectText}
|
|
151
|
-
// eslint-disable-next-line react/no-danger
|
|
152
|
-
dangerouslySetInnerHTML={{ __html: redirectText }}
|
|
153
|
-
/>
|
|
154
|
-
)}
|
|
155
|
-
</div>
|
|
156
|
-
</div>
|
|
157
|
-
</>
|
|
158
|
-
)}
|
|
159
|
-
</>
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export const Head = ({ pageContext }) => (
|
|
164
|
-
<HeadData page={pageContext.page} siteInfo={pageContext.siteInfo} />
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
TrackerGeo.propTypes = {
|
|
168
|
-
redirectText: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
169
|
-
mainText: PropTypes.string,
|
|
170
|
-
bgImage: PropTypes.string,
|
|
171
|
-
bgVideo: PropTypes.string,
|
|
172
|
-
path: PropTypes.string,
|
|
173
|
-
logo: PropTypes.string,
|
|
174
|
-
counter: PropTypes.bool,
|
|
175
|
-
redirectTimer: PropTypes.number,
|
|
176
|
-
operatorLogo: PropTypes.bool,
|
|
177
|
-
operatorLogoWidth: PropTypes.string,
|
|
178
|
-
operatorLogoHeight: PropTypes.string,
|
|
179
|
-
pageContext: PropTypes.shape({
|
|
180
|
-
operatorsByMarket: PropTypes.shape({
|
|
181
|
-
bonus: PropTypes.shape({
|
|
182
|
-
operator_name: PropTypes.string,
|
|
183
|
-
}),
|
|
184
|
-
name: PropTypes.string,
|
|
185
|
-
logo: PropTypes.shape({}),
|
|
186
|
-
links: PropTypes.shape({
|
|
187
|
-
main: PropTypes.string,
|
|
188
|
-
terms_and_conditions: PropTypes.string,
|
|
189
|
-
}),
|
|
190
|
-
}).isRequired,
|
|
191
|
-
page: PropTypes.shape({
|
|
192
|
-
template: PropTypes.string,
|
|
193
|
-
}),
|
|
194
|
-
}),
|
|
195
|
-
styles: PropTypes.shape({}),
|
|
196
|
-
};
|