gatsby-core-theme 22.0.4 → 22.0.6

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 CHANGED
@@ -1,3 +1,28 @@
1
+ ## [22.0.6](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v22.0.5...v22.0.6) (2023-05-31)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add free-casinos as well ([b36474e](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/b36474e236aaa2c3cb6156ab6b127b3f2361b9a3))
7
+ * multiple market bugs ([9ea03b7](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/9ea03b74137c9ea5013cb68467623698040ac89a))
8
+ * multiple market bugs ([caf25e3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/caf25e31d2d664e727092c3c085dfab59e86b857))
9
+
10
+
11
+ * Merge branch 'tm-3473-multiple-market-fixes' into 'master' ([37556d3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/37556d3ab485fc89c32b46391c7a16839049ad58))
12
+ * Merge branch 'bug-fix-request-add-not-recommended' into 'master' ([27b345b](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/27b345bdda19e4151c82edb7377a176b0894fc44))
13
+
14
+ ## [22.0.5](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v22.0.4...v22.0.5) (2023-05-18)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * add not recommended to the cardsv2 filter constant ([09475f7](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/09475f7ad3c6043220f975dacfd0126514859da4))
20
+ * preview, translations and menu item fixes ([3ed8ba5](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/3ed8ba5c25dfa7ae6fa041adbacf26e788ce190b))
21
+
22
+
23
+ * Merge branch 'tm-3461-preview-translations-menu' into 'master' ([635247b](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/635247baf344c467106d5c97fc6af9e919e4cd70))
24
+ * Merge branch 'bug-fix-request-add-not-recommended' into 'master' ([a0e8d09](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/a0e8d090bd6cff242002e164e6ac7fc43f139db0))
25
+
1
26
  ## [22.0.4](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v22.0.3...v22.0.4) (2023-05-17)
2
27
 
3
28
 
@@ -257,7 +257,7 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
257
257
  siteInfo,
258
258
  autogenerated,
259
259
  siteSchema,
260
- translations,
260
+ translations: processed.relations.translations[page.language],
261
261
  authors,
262
262
  ...themeOptions,
263
263
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "22.0.4",
3
+ "version": "22.0.6",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "main": "index.js",
6
6
  "GATSBY_RECAPTCHA_SITEKEY": "6LfoyvMUAAAAAO4nl_MQnqHb4XdHxEiu5cXgIqeB",
@@ -18,6 +18,7 @@ const App = ({ pageContext }) => {
18
18
  getPreview(
19
19
  pageContext.siteName,
20
20
  !staticPath ? searchParams.get('path') || '/' : staticPath,
21
+ searchParams.get('market_id'),
21
22
  pageContext
22
23
  ).then((previewResponse) => {
23
24
  if (previewResponse.page) {
@@ -39,12 +40,12 @@ const App = ({ pageContext }) => {
39
40
  window.location = `${window.location.origin}/preview?path=/`;
40
41
  }
41
42
  getData(searchParams);
42
- globalHistory.listen(({ location }) => {
43
- const searchParams2 =
44
- typeof window !== 'undefined' ? new URLSearchParams(location.search) : null;
45
- setIsLoading(true);
46
- window.location = `${window.location.origin}/preview?path=${searchParams2.get('path')}`;
47
- });
43
+ // globalHistory.listen(({ location }) => {
44
+ // const searchParams2 =
45
+ // typeof window !== 'undefined' ? new URLSearchParams(location.search) : null;
46
+ // setIsLoading(true);
47
+ // window.location = `${window.location.origin}/preview?path=${searchParams2.get('path')}&market_id=${searchParams2.get('market_id')}`;
48
+ // });
48
49
  }
49
50
  // eslint-disable-next-line react-hooks/exhaustive-deps
50
51
  }, []);
@@ -4,7 +4,7 @@ import '@testing-library/jest-dom/extend-expect';
4
4
 
5
5
  import getPageData from '~tests/factories/pages/default.factory';
6
6
  import MainProvider from '~context/MainProvider';
7
- import Breadcrumbs from '.';
7
+ import Breadcrumbs from './index';
8
8
 
9
9
  function renderComponent(pageData) {
10
10
  return render(
@@ -72,6 +72,15 @@ describe('Show Breadcrumbs in a page', () => {
72
72
  const { getByText } = renderComponent(page);
73
73
  expect(getByText('Simple Casino')).toBeTruthy();
74
74
  });
75
+ test('Breadcrumbs with multiple markets', () => {
76
+ const data = getPageData();
77
+ const { getByText } = render(
78
+ <Breadcrumbs page={data} markets={{ en_za: { path_prefix: 'en' } }} />
79
+ );
80
+ expect(getByText('The Page Title')).toBeTruthy();
81
+ expect(getByText('Home').getAttribute('href')).toEqual('/en');
82
+ expect(getByText('Sport').getAttribute('href')).toEqual('/sport');
83
+ });
75
84
  });
76
85
  afterEach(() => {
77
86
  cleanup();
@@ -8,8 +8,9 @@ import keygen from '~helpers/keygen';
8
8
  import { translate } from '~helpers/getters';
9
9
  import { Context } from '~context/MainProvider';
10
10
 
11
- function Breadcrumbs({ page, separator = <span> / </span> }) {
11
+ function Breadcrumbs({ page, separator = <span> / </span>, markets }) {
12
12
  const { translations } = useContext(Context) || {};
13
+ const activeMarket = markets && markets[page.market];
13
14
 
14
15
  if (page.path === '/') {
15
16
  return <></>;
@@ -29,7 +30,11 @@ function Breadcrumbs({ page, separator = <span> / </span> }) {
29
30
  {isPPC ? (
30
31
  home
31
32
  ) : (
32
- <Link to="/" title="Home" className="breadcrumbs-gtm">
33
+ <Link
34
+ to={(activeMarket && activeMarket.path_prefix) || '/'}
35
+ title="Home"
36
+ className="breadcrumbs-gtm"
37
+ >
33
38
  {home}
34
39
  </Link>
35
40
  )}
@@ -55,7 +60,11 @@ function Breadcrumbs({ page, separator = <span> / </span> }) {
55
60
  }
56
61
 
57
62
  Breadcrumbs.propTypes = {
63
+ markets: PropTypes.shape({
64
+ path_prefix: PropTypes.string,
65
+ }),
58
66
  page: PropTypes.shape({
67
+ market: PropTypes.string,
59
68
  title: PropTypes.string,
60
69
  path: PropTypes.string,
61
70
  breadcrumbs: PropTypes.arrayOf(PropTypes.shape({})),
@@ -59,7 +59,7 @@ function Header({ section, content = null, backgroundImage = true, showAuthor =
59
59
  }`}
60
60
  >
61
61
  <div className={styles.topSection || ''}>
62
- {section.page.path && <Breadcrumbs page={section.page} />}
62
+ {section.page.path && <Breadcrumbs markets={section.allMarkets} page={section.page} />}
63
63
  {Author && (
64
64
  <div className={styles.authorContainer || ''}>
65
65
  <Author
@@ -90,6 +90,7 @@ function Header({ section, content = null, backgroundImage = true, showAuthor =
90
90
  Header.propTypes = {
91
91
  content: PropTypes.element,
92
92
  section: PropTypes.shape({
93
+ allMarkets: PropTypes.shape([PropTypes.shape({})]),
93
94
  page: PropTypes.shape({
94
95
  template: PropTypes.string,
95
96
  relation_type: PropTypes.string,
@@ -15,7 +15,9 @@ export default {
15
15
  'norskespilleautomater.com': ['inactive', 'blacklisted', 'coming_soon'],
16
16
  'playcasino.co.za': ['inactive', 'blacklisted', 'coming_soon'],
17
17
  'onlinegamblingsa.co.za': ['inactive', 'blacklisted', 'coming_soon'],
18
- 'onlinegamblingsa.com': ['inactive', 'blacklisted', 'coming_soon'],
18
+ 'onlinegamblingsa.com': ['inactive', 'blacklisted', 'coming_soon', 'not_recommended'],
19
+ 'onlinecasinosouthafrica.net': ['inactive', 'blacklisted', 'coming_soon', 'not_recommended'],
20
+ 'free-casinos.co.za': ['inactive', 'blacklisted', 'coming_soon', 'not_recommended'],
19
21
  'sporttheme.com': ['inactive', 'blacklisted'],
20
22
  'partnerships.gigmedia.com': ['inactive', 'blacklisted'],
21
23
  'habibibet.org': ['inactive', 'blacklisted'],
@@ -6,25 +6,27 @@ const API_URL = process.env.GATSBY_API_URL;
6
6
 
7
7
  /* eslint no-console: ["error", { allow: ["log"] }] */
8
8
 
9
- export async function getPreview(siteName, page = null, themeOptions) {
9
+ export async function getPreview(siteName, page = null, marketId, themeOptions) {
10
10
  return new Promise((resolve, reject) => {
11
11
  axios
12
12
  .get(
13
- `${API_URL}/sites/v0.1/pages/sorted?site_name=${siteName}&path=${page}&preview=1&relations=1`
13
+ `${API_URL}/sites/v0.1/pages/sorted?site_name=${siteName}&path=${page}&market_id=${marketId}&preview=1&relations=1`
14
14
  )
15
15
  .then((response) => {
16
16
  console.log(response);
17
+ const pagePreview = response.data.result.pages.preview;
17
18
  const processed = processor.run(response.data.result, themeOptions);
18
- const siteMarket = Object.keys(processed.site_markets)[0];
19
19
 
20
- const pagePreview = processed.pages[siteMarket].preview[0];
21
- const pagePreviewProcessed = processed.pages[siteMarket][pagePreview.relation_type].find(
22
- (page) => page.path === pagePreview.path
23
- );
20
+ const { path } = processed.pages[pagePreview.market].preview[0];
21
+
22
+ const pagePreviewProcessed = processed.pages[pagePreview.market][
23
+ pagePreview.relation_type
24
+ // eslint-disable-next-line no-shadow
25
+ ].find((page) => page.path === path);
24
26
 
25
27
  resolve({
26
- marketSections: processed.market_sections[siteMarket],
27
- prefilledModules: processed.prefilled_market_modules[siteMarket],
28
+ marketSections: processed.market_sections[pagePreview.market],
29
+ prefilledModules: processed.prefilled_market_modules[pagePreview.market],
28
30
  page: pagePreviewProcessed,
29
31
  allMarkets: processed.site_markets,
30
32
  siteInfo: processed.general,
@@ -8,7 +8,9 @@ export function previewFormat(path) {
8
8
  }
9
9
 
10
10
  export function previewPath(path) {
11
- return `/preview?path=${previewFormat(path)}`;
11
+ // eslint-disable-next-line no-restricted-globals
12
+ const searchParams2 = typeof window !== 'undefined' ? new URLSearchParams(location.search) : null;
13
+ return `/preview?path=${previewFormat(path)}&market_id=${searchParams2.get('market_id')}`;
12
14
  }
13
15
 
14
16
  export function formatPath(path) {
@@ -26,13 +26,13 @@ describe('Path format component', () => {
26
26
  const path = previewPath('/test/link');
27
27
  expect(typeof path).toEqual('string');
28
28
 
29
- expect(path).toBe('/preview?path=test/link');
29
+ expect(path).toBe('/preview?path=test/link&market_id=null');
30
30
  });
31
31
 
32
32
  test('preview mode path navigation keep no initial / on path param', () => {
33
33
  const path = previewPath('test/link');
34
34
 
35
35
  expect(typeof path).toEqual('string');
36
- expect(path).toBe('/preview?path=test/link');
36
+ expect(path).toBe('/preview?path=test/link&market_id=null');
37
37
  });
38
38
  });
@@ -116,3 +116,17 @@ export function removeCurrentPage(list, id) {
116
116
  }
117
117
  return list;
118
118
  }
119
+
120
+ export function updateMenuPrefixPath(menu, prefixPath) {
121
+ menu.map((item) => {
122
+ if (item.value) {
123
+ item.value = item.value === '/' ? prefixPath : `${prefixPath}/${item.value}`;
124
+ }
125
+
126
+ if (item.children) {
127
+ updateMenuPrefixPath(item.children, prefixPath);
128
+ }
129
+
130
+ return true;
131
+ });
132
+ }
@@ -1,4 +1,10 @@
1
- import { groupBy, removeDuplicates, clonePageForCards, removeCurrentPage } from './common';
1
+ import {
2
+ groupBy,
3
+ removeDuplicates,
4
+ clonePageForCards,
5
+ removeCurrentPage,
6
+ updateMenuPrefixPath,
7
+ } from './common';
2
8
  import getPageDataList from '~tests/factories/pages/list.factory';
3
9
 
4
10
  describe('Common Helper', () => {
@@ -30,4 +36,54 @@ describe('Common Helper', () => {
30
36
  const result = removeCurrentPage(data, 2);
31
37
  expect(result.id === 2).toBeFalsy();
32
38
  });
39
+
40
+ test('menu update function', () => {
41
+ const data = [
42
+ {
43
+ value: 'test',
44
+ children: [
45
+ {
46
+ value: 'null',
47
+ },
48
+ {
49
+ value: 'test3',
50
+ children: [
51
+ {
52
+ value: 'test4',
53
+ children: [
54
+ {
55
+ value: 'test5',
56
+ },
57
+ ],
58
+ },
59
+ ],
60
+ },
61
+ {
62
+ value: 'test6',
63
+ },
64
+ ],
65
+ },
66
+ {
67
+ value: 'test3',
68
+ children: [
69
+ {
70
+ value: 'test4',
71
+ children: [
72
+ {
73
+ value: 'test5',
74
+ },
75
+ ],
76
+ },
77
+ ],
78
+ },
79
+ ];
80
+
81
+ updateMenuPrefixPath(data, 'prefix/');
82
+ data.map((menuItem) => {
83
+ if (menuItem.value) {
84
+ expect(menuItem.value).toContain('prefix/');
85
+ }
86
+ return true;
87
+ });
88
+ });
33
89
  });
@@ -14,7 +14,7 @@ import { generatePlaceholderString } from '../generators';
14
14
  // eslint-disable-next-line import/no-cycle
15
15
  import { shouldSavePrefilled, processModule } from './modules';
16
16
  // eslint-disable-next-line import/no-cycle
17
- import { clonePageForCards, groupBy, removeTags } from './common';
17
+ import { clonePageForCards, groupBy, removeTags, updateMenuPrefixPath } from './common';
18
18
  import { prepareSportsData, addSportsDataToPage, addExtraFieldsToShowcaseEvents } from './sports';
19
19
  import { processRelations } from './relations';
20
20
  import { zeroPadding } from '../schedule';
@@ -96,7 +96,7 @@ export function transform(response) {
96
96
  }
97
97
 
98
98
  const savedModules = {};
99
- export function processSections(sections, skipPost = false, page, translations) {
99
+ export function processSections(sections, skipPost = false, page, translations, markets) {
100
100
  const siteName = page && page.siteInfo && page.siteInfo.site_name;
101
101
  // pagedId we will use it just on operator review pages
102
102
  const pageId = page ? page.id : null;
@@ -127,7 +127,8 @@ export function processSections(sections, skipPost = false, page, translations)
127
127
  previewMode,
128
128
  pageId,
129
129
  translations,
130
- relationData
130
+ relationData,
131
+ markets
131
132
  );
132
133
 
133
134
  if (shouldSavePrefilled(module, siteName)) {
@@ -255,10 +256,22 @@ export default {
255
256
  sportsData = prepareSportsData(data.relations.sports_data);
256
257
  }
257
258
 
259
+ menus = data.menus;
260
+
261
+ // Menu changes when there is a path prefix configured on hercules
262
+ Object.keys(menus).forEach((menu) => {
263
+ if (data.site_markets[menus[menu].market].path_prefix) {
264
+ updateMenuPrefixPath(
265
+ menus[menu].children,
266
+ data.site_markets[menus[menu].market].path_prefix
267
+ );
268
+ }
269
+ });
270
+
258
271
  Object.keys(data.site_markets).forEach((market) => {
259
272
  relations = data.relations;
260
273
  pages = transformedPages[market];
261
- menus = data.menus;
274
+
262
275
  prefilledMarketModules = data.prefilled_market_modules || {};
263
276
  prefilledMarketModulesRaw = cloneDeep(data.prefilled_market_modules);
264
277
  Object.keys(transformedPages[market]).forEach((pageType) => {
@@ -290,7 +303,13 @@ export default {
290
303
  if (pageBreadcrumbIds) {
291
304
  let breadcrumbsArray = [];
292
305
  for (let i = 0; i < pageBreadcrumbIds.length; i += 1) {
293
- breadcrumbsArray = [...breadcrumbsArray, ...data.breadcrumbs[pageBreadcrumbIds[i]]];
306
+ const breadcrumbData = cloneDeep(data.breadcrumbs[pageBreadcrumbIds[i]]);
307
+
308
+ if (data.site_markets[market].path_prefix) {
309
+ breadcrumbData[0].path = `${data.site_markets[market].path_prefix}/${breadcrumbData[0].path}`;
310
+ }
311
+
312
+ breadcrumbsArray = [...breadcrumbsArray, ...breadcrumbData];
294
313
  }
295
314
  transformedPages[market][pageType][index].breadcrumbs = breadcrumbsArray;
296
315
  }
@@ -406,7 +425,8 @@ export default {
406
425
  data.market_sections[market],
407
426
  true,
408
427
  null,
409
- translations
428
+ translations,
429
+ data.site_markets
410
430
  );
411
431
  }
412
432
 
@@ -433,7 +453,13 @@ export default {
433
453
  });
434
454
 
435
455
  transformedPages[market][pageType][index] = Object.assign(page, {
436
- sections: processSections(page.sections, false, page, translations),
456
+ sections: processSections(
457
+ page.sections,
458
+ false,
459
+ page,
460
+ translations,
461
+ data.site_markets
462
+ ),
437
463
  });
438
464
  }
439
465
  });
@@ -265,7 +265,7 @@ export function processArchiveModule(module, pages) {
265
265
  module.numOfPages = 1;
266
266
  }
267
267
 
268
- export function processTopListModule(module, relations, pages) {
268
+ export function processTopListModule(module, relations, pages, markets) {
269
269
  module.items = module.items.map((listItem) => {
270
270
  listItem.items = listItem.items.map((item) => {
271
271
  // Remove the ribbons if are empty, will be add ribbons from operator
@@ -282,6 +282,18 @@ export function processTopListModule(module, relations, pages) {
282
282
  clone.authorPath =
283
283
  operatorPage[0].author.profile_page_path && operatorPage[0].author.profile_page_path;
284
284
  }
285
+
286
+ // Multiple market fix
287
+ if (
288
+ item.review_link &&
289
+ operatorPage.length >= 1 &&
290
+ markets &&
291
+ markets[operatorPage[0].market] &&
292
+ markets[operatorPage[0].market].path_prefix
293
+ ) {
294
+ item.review_link = `${markets[operatorPage[0].market].path_prefix}/${item.review_link}`;
295
+ }
296
+
285
297
  delete clone.software;
286
298
  delete clone.bonus.deposit_methods;
287
299
  return Object.assign(clone, item);
@@ -309,7 +321,8 @@ export function processModule(
309
321
  previewMode,
310
322
  pageId,
311
323
  translations,
312
- relationData
324
+ relationData,
325
+ markets
313
326
  ) {
314
327
  module.module_title =
315
328
  module.module_title &&
@@ -326,7 +339,7 @@ export function processModule(
326
339
  } else if (module.name === 'archive' && previewMode) {
327
340
  processArchiveModule(module, pages);
328
341
  } else if (module.name === 'top_list') {
329
- processTopListModule(module, relations, pages);
342
+ processTopListModule(module, relations, pages, markets);
330
343
  } else if (module.name === 'menu' && menus && menus[module.menu_id]) {
331
344
  module = Object.assign(module, menus[module.menu_id]);
332
345
  }
@@ -172,6 +172,23 @@ describe('Modules Helper', () => {
172
172
  expect(singleToplistData.items[0].items[0].bonus.deposit_methods).toHaveLength(1);
173
173
  });
174
174
 
175
+ test('Process TopList module multiple market', () => {
176
+ processTopListModule(
177
+ singleToplistData,
178
+ relationData,
179
+ {
180
+ operator: [{ relation_id: 6342, market: 'en_za' }],
181
+ },
182
+ { en_za: { path_prefix: 'en' } }
183
+ );
184
+
185
+ expect(singleToplistData.items[0].items[0].review_link).toEqual('en/slotum');
186
+ expect(singleToplistData.items[0].items[0].rating_casino).toEqual('4');
187
+ expect(singleToplistData.items[0].items[0].selling_points).toHaveLength(2);
188
+ expect(singleToplistData.items[0].items[0].short_name).toEqual('slotum');
189
+ expect(singleToplistData.items[0].items[0].bonus.deposit_methods).toHaveLength(1);
190
+ });
191
+
175
192
  test('Should Generate Prefilled', () => {
176
193
  const objects = objectsHolder('prefilledModules');
177
194
  objects.forEach((prefilled) => {
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  // eslint-disable-next-line import/no-extraneous-dependencies
3
3
  import { Link } from 'gatsby';
4
- import { navigate } from '@reach/router';
5
4
  import PropTypes from 'prop-types';
6
5
  import { previewFormat, previewPath, formatPath } from '~helpers/path';
7
6
 
@@ -30,7 +29,7 @@ function LinkCustom({
30
29
  {...other}
31
30
  onClick={(event) => {
32
31
  event.preventDefault();
33
- navigate(previewPath(to));
32
+ window.location = previewPath(to);
34
33
  }}
35
34
  >
36
35
  {children}
@@ -439,7 +439,7 @@ export const singleToplistData = {
439
439
  short_name: 'slotum',
440
440
  logo_url: 'slotum-casino-logo-transparentpng6b10407566-original.png',
441
441
  rating: '4',
442
- review_link: '/slotum',
442
+ review_link: 'slotum',
443
443
  selling_points: ['200% Bonus', 'Nice design'],
444
444
  links: {
445
445
  main: 'https://media.dunderaffiliates.com/redirect.aspx?pid=630524&bid=1477',
@@ -8,6 +8,7 @@ export default function getPageData() {
8
8
  title: 'The Page Title',
9
9
  relation_type: 'operator',
10
10
  type: 'operator',
11
+ market: 'en_za',
11
12
  name: 'Rizk Casino',
12
13
  logo_url: '#',
13
14
  banner: '313df295c19d7c5f137ceda9d0cc5df7.jpeg',