gatsby-core-theme 1.0.1 → 1.1.0
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 +43 -0
- package/gatsby-config.js +2 -0
- package/gatsby-node.esm.js +10 -1
- package/package.json +4 -1
- package/src/components/molecules/header/header.module.scss +12 -0
- package/src/components/molecules/header/index.js +6 -9
- package/src/helpers/getters.js +4 -16
- package/src/helpers/processor/common.js +14 -0
- package/src/helpers/processor/common.test.js +9 -1
- package/src/helpers/processor/modules.js +98 -34
- package/src/helpers/processor/modules.test.js +66 -1
- package/src/hooks/gatsby-img/index.js +17 -18
- package/tests/factories/modules/toplist.factory.js +120 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,46 @@
|
|
|
1
|
+
# [1.1.0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.0.1...v1.1.0) (2021-09-22)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* added tests for cardsv2 functions and fixed some errors ([03452ff](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/03452ff6adfda6210530b4e26d878910a7eefecc))
|
|
7
|
+
* added tests for process toplist ([9070692](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/90706924121fb9553b8cc268672a654aa0961c6f))
|
|
8
|
+
* fixed a case that was not working, and refactored processCardsV2 function ([1a8c809](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/1a8c809ce8675d2c7538538dbdfae3be4b076dd3))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Code Refactoring
|
|
12
|
+
|
|
13
|
+
* add preact and gatsby image to header ([0f2d32f](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/0f2d32f0d892643760ead49cfc2534cd1eaf2e63))
|
|
14
|
+
* created reusable filter pages function ([53fff79](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/53fff79f1980c5d915f5b71db341d2f3d822bb13))
|
|
15
|
+
* refactor fitlerpages function ([78bb571](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/78bb5711286d2268b5447f4477d224ed9a3e12e0))
|
|
16
|
+
* remove commented code ([7dbd291](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/7dbd291f7c3f774d5bf157f657cd38ae43f58661))
|
|
17
|
+
* remove getMarketCountryNames from getters ([872e3f3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/872e3f30c174b9803540b0fa396092c8db293ab8))
|
|
18
|
+
* update getMarketCountryName getter func ([2b69823](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/2b69823b7ce45dbff9b500a27a4e50618f2dca1c))
|
|
19
|
+
* wip on cardsv2 seperation ([b03b56e](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/b03b56e4befd85526245b993190b072b080aad91))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Config
|
|
23
|
+
|
|
24
|
+
* archive set to show only custom content pages for rage-seo ([8fa126f](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/8fa126f40cf5c74e7b3c792aca5fd772e5db9bc9))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
* Merge branch 'tm-2440-archive-fix' into 'master' ([590807a](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/590807a151ed2ea1a62c22495571dfac6e6ac8a3))
|
|
28
|
+
* Merge branch 'tm-2441-performance-improvements' into 'master' ([3667155](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/366715556a25678e788fb35e93986e52d12be3b5))
|
|
29
|
+
* Merge branch 'tm-2411-cards-v2-phase-two' into 'master' ([2d54250](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/2d542504b37197f9fc0fc3abb17be253dba2463d))
|
|
30
|
+
* Merge branch 'tm-2409-update-rage-ppc-simplify-watchfooty' into 'master' ([37f146c](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/37f146cd06a4df8cf000d8452ee761469cd482bb))
|
|
31
|
+
* Merge branch 'master' into tm-2409-update-rage-ppc-simplify-watchfooty ([2195df3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/2195df37d4c4f3713bb9f3216c80406f0ea14391))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
* add gatsby-image plugin to demo site ([6cd736e](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/6cd736e164c4d4695852d423ac552ff46ddab6ba))
|
|
37
|
+
* added cardsv2 phase two ([71538d9](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/71538d94662d5bc7c94c0b4463d17138471e3b92))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Tests
|
|
41
|
+
|
|
42
|
+
* changes to test script to accommodate gatsby-img ([7f70025](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/7f700255e15cc2b1e26de75fbcc18a7389aa5f78))
|
|
43
|
+
|
|
1
44
|
## [1.0.1](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v1.0.0...v1.0.1) (2021-09-10)
|
|
2
45
|
|
|
3
46
|
|
package/gatsby-config.js
CHANGED
package/gatsby-node.esm.js
CHANGED
|
@@ -28,7 +28,16 @@ function createArchivePage(pageObject, marketSections, prefilledModules, createP
|
|
|
28
28
|
(module) => module.name === 'archive'
|
|
29
29
|
);
|
|
30
30
|
const archiveModule = pageObject.sections.main.modules[archiveModuleIndex];
|
|
31
|
-
|
|
31
|
+
let archivePages = cloneDeep(pages[pageObject.market][archiveModule.model_type]);
|
|
32
|
+
|
|
33
|
+
if (process.env.CUSTOM_CONTENT_PAGES_PATH && archivePages) {
|
|
34
|
+
// eslint-disable-next-line array-callback-return
|
|
35
|
+
archivePages = archivePages.filter((item) => {
|
|
36
|
+
if (item.path.includes(process.env.CUSTOM_CONTENT_PAGES_PATH)) {
|
|
37
|
+
return item;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
32
41
|
|
|
33
42
|
if (!archivePages) {
|
|
34
43
|
console.log(`Archive for ${pageObject.path} broken`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gatsby-core-theme",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Gatsby Theme NPM Package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"GATSBY_RECAPTCHA_SITEKEY": "6LfoyvMUAAAAAO4nl_MQnqHb4XdHxEiu5cXgIqeB",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"gatsby-plugin-loadable-components-ssr": "^3.3.0",
|
|
38
38
|
"gatsby-plugin-manifest": "^3.3.0",
|
|
39
39
|
"gatsby-plugin-postcss": "^4.3.0",
|
|
40
|
+
"gatsby-plugin-preact": "^5.13.0",
|
|
40
41
|
"gatsby-plugin-react-helmet": "^4.3.0",
|
|
41
42
|
"gatsby-plugin-sass": "^4.3.0",
|
|
42
43
|
"gatsby-plugin-sharp": "^3.3.0",
|
|
@@ -50,6 +51,8 @@
|
|
|
50
51
|
"node-sass": "5.0.0",
|
|
51
52
|
"normalize.css": "^8.0.1",
|
|
52
53
|
"postcss": "^8.2.10",
|
|
54
|
+
"preact": "^10.5.14",
|
|
55
|
+
"preact-render-to-string": "^5.1.19",
|
|
53
56
|
"prop-types": "15.7.2",
|
|
54
57
|
"react": "^17.0.2",
|
|
55
58
|
"react-cookies": "^0.1.1",
|
|
@@ -9,6 +9,18 @@
|
|
|
9
9
|
object-fit: cover;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
.bgImage {
|
|
13
|
+
height: 0;
|
|
14
|
+
> div {
|
|
15
|
+
position: absolute;
|
|
16
|
+
height: 100%;
|
|
17
|
+
width: 100%;
|
|
18
|
+
left: 0;
|
|
19
|
+
object-fit: cover;
|
|
20
|
+
background-color: black;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
12
24
|
.headerContent {
|
|
13
25
|
z-index: 1;
|
|
14
26
|
padding: 2.4rem;
|
|
@@ -6,6 +6,9 @@ import Breadcrumbs from '~atoms/breadcrumbs';
|
|
|
6
6
|
import Author from '~atoms/author';
|
|
7
7
|
import { imagePrettyUrl, getSectionExtraField } from '~helpers/getters';
|
|
8
8
|
|
|
9
|
+
// eslint-disable-next-line import/no-named-as-default
|
|
10
|
+
import Image from '../../../hooks/gatsby-img';
|
|
11
|
+
|
|
9
12
|
/* eslint-disable camelcase, react/no-danger */
|
|
10
13
|
|
|
11
14
|
function Header({ section, content = null, backgroundImage = true }) {
|
|
@@ -14,15 +17,9 @@ function Header({ section, content = null, backgroundImage = true }) {
|
|
|
14
17
|
const uploadedBg = imagePrettyUrl(backgroundImageValue);
|
|
15
18
|
|
|
16
19
|
let backgroundImg = (
|
|
17
|
-
<
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
srcSet="../../../images/headerBackground.webp 1440w"
|
|
21
|
-
type="image/webp"
|
|
22
|
-
/>
|
|
23
|
-
<source srcSet="../../../images/headerBackgroundMob.webp 370w" type="image/webp" />
|
|
24
|
-
<img src="../../../images/headerBackground.png" alt="header" />
|
|
25
|
-
</picture>
|
|
20
|
+
<div className={styles.bgImage}>
|
|
21
|
+
<Image filename="headerBackground.png" alt="header" />
|
|
22
|
+
</div>
|
|
26
23
|
);
|
|
27
24
|
if (backgroundImageValue) {
|
|
28
25
|
backgroundImg = <img src={uploadedBg} alt="header" className={styles.headerImage} />;
|
package/src/helpers/getters.js
CHANGED
|
@@ -32,6 +32,7 @@ export function getExtraField(extraFields, key, defaultValue) {
|
|
|
32
32
|
export function getSection(shortCode, pageContext) {
|
|
33
33
|
const page = pageContext?.page;
|
|
34
34
|
const marketSections = pageContext?.marketSections;
|
|
35
|
+
// eslint-disable-next-line
|
|
35
36
|
if (!page || !page.hasOwnProperty('sections') || !page.sections.hasOwnProperty(shortCode)) {
|
|
36
37
|
return null;
|
|
37
38
|
}
|
|
@@ -166,6 +167,7 @@ export function getBonus(name, operator) {
|
|
|
166
167
|
// site data
|
|
167
168
|
if (
|
|
168
169
|
operator.one_liners &&
|
|
170
|
+
// eslint-disable-next-line
|
|
169
171
|
operator.one_liners.hasOwnProperty(name) &&
|
|
170
172
|
operator.one_liners[name].one_liner !== ''
|
|
171
173
|
) {
|
|
@@ -175,6 +177,7 @@ export function getBonus(name, operator) {
|
|
|
175
177
|
if (
|
|
176
178
|
operator.bonus &&
|
|
177
179
|
operator.bonus.one_liners &&
|
|
180
|
+
// eslint-disable-next-line
|
|
178
181
|
operator.bonus.one_liners.hasOwnProperty(name)
|
|
179
182
|
) {
|
|
180
183
|
return operator.bonus.one_liners[name] || null;
|
|
@@ -298,6 +301,7 @@ export function getFirstModuleByName(section, moduleName) {
|
|
|
298
301
|
}
|
|
299
302
|
|
|
300
303
|
export function translate(translations, key, defaultValue = '') {
|
|
304
|
+
// eslint-disable-next-line
|
|
301
305
|
if (translations?.hasOwnProperty(key)) {
|
|
302
306
|
return translations[key];
|
|
303
307
|
}
|
|
@@ -307,19 +311,3 @@ export function translate(translations, key, defaultValue = '') {
|
|
|
307
311
|
export function getAws(imageName) {
|
|
308
312
|
return `https://assets-srv.s3.eu-west-1.amazonaws.com/${imageName}`;
|
|
309
313
|
}
|
|
310
|
-
|
|
311
|
-
// Add more countries as needed
|
|
312
|
-
export function getMarketCountryName(marketId) {
|
|
313
|
-
let countryName;
|
|
314
|
-
switch (marketId) {
|
|
315
|
-
case 'dk_da':
|
|
316
|
-
countryName = 'denmark';
|
|
317
|
-
break;
|
|
318
|
-
case 'fi_fi':
|
|
319
|
-
countryName = 'finland';
|
|
320
|
-
break;
|
|
321
|
-
default:
|
|
322
|
-
countryName = null;
|
|
323
|
-
}
|
|
324
|
-
return countryName;
|
|
325
|
-
}
|
|
@@ -74,3 +74,17 @@ export function clonePageForCards(item, siteId) {
|
|
|
74
74
|
|
|
75
75
|
return object;
|
|
76
76
|
}
|
|
77
|
+
|
|
78
|
+
export function removeDuplicates(list, key) {
|
|
79
|
+
if (!list || !key) {
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return list.reduce((filtered, current) => {
|
|
84
|
+
const duplicateItem = filtered.find((item) => item[key] === current[key]);
|
|
85
|
+
if (!duplicateItem) {
|
|
86
|
+
return filtered.concat([current]);
|
|
87
|
+
}
|
|
88
|
+
return filtered;
|
|
89
|
+
}, []);
|
|
90
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { groupBy } from './common';
|
|
1
|
+
import { groupBy, removeDuplicates } from './common';
|
|
2
2
|
import getPageDataList from '~tests/factories/pages/list.factory';
|
|
3
3
|
|
|
4
4
|
describe('Common Helper', () => {
|
|
@@ -10,4 +10,12 @@ describe('Common Helper', () => {
|
|
|
10
10
|
const pagesMappedByMetaTitle = groupBy(getPageDataList(pagesNum), 'meta_title');
|
|
11
11
|
expect(Object.keys(pagesMappedByMetaTitle).length).toBe(2);
|
|
12
12
|
});
|
|
13
|
+
|
|
14
|
+
test('Remove duplicates function', () => {
|
|
15
|
+
const array = getPageDataList(2);
|
|
16
|
+
array[2] = { id: 1, name: 'Test' };
|
|
17
|
+
|
|
18
|
+
const filtered = removeDuplicates(array, 'id');
|
|
19
|
+
expect(filtered).toHaveLength(2);
|
|
20
|
+
});
|
|
13
21
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cloneDeep, pick, sampleSize } from 'lodash';
|
|
2
2
|
|
|
3
3
|
// eslint-disable-next-line import/no-cycle
|
|
4
|
-
import { clonePageForCards, groupBy } from './common';
|
|
4
|
+
import { clonePageForCards, groupBy, removeDuplicates } from './common';
|
|
5
5
|
import { topListPickKeys } from '../../constants/pick-keys';
|
|
6
6
|
|
|
7
7
|
const pagesGroupedByTemplateId = [];
|
|
@@ -33,11 +33,77 @@ export function processCardsModule(module, pages, pagesCloned, pagesMappedById)
|
|
|
33
33
|
module.items = module.items.map((item) => clonePageForCards(cloneDeep(item)));
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
export function filterPages(pages, selectedFilters, key) {
|
|
37
|
+
let filteredPages = [];
|
|
38
|
+
|
|
39
|
+
if (selectedFilters) {
|
|
40
|
+
selectedFilters.forEach((id) => {
|
|
41
|
+
filteredPages = filteredPages.concat(
|
|
42
|
+
pages.filter((page) => {
|
|
43
|
+
const compareArr = !Array.isArray(page[key]) ? [page[key]] : page[key];
|
|
44
|
+
return compareArr.includes(id);
|
|
45
|
+
})
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
filteredPages = pages;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return filteredPages;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function filterGames(pages, selectedCategories, selectedProviders) {
|
|
56
|
+
const pagesFiltered = [];
|
|
57
|
+
if (!selectedCategories && !selectedProviders) {
|
|
58
|
+
return pages;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
pages.forEach((page) => {
|
|
62
|
+
page.relation.game_categories.forEach((game) => {
|
|
63
|
+
if (selectedCategories && selectedCategories.includes(game.id)) {
|
|
64
|
+
pagesFiltered.push(page);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
if (selectedProviders && selectedProviders.includes(page.relation.game_provider.id)) {
|
|
68
|
+
pagesFiltered.push(page);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return pagesFiltered;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function filterOperators(pages, selectedProviders, selectedTypes) {
|
|
76
|
+
const pagesFiltered = [];
|
|
77
|
+
if (!selectedTypes && !selectedProviders) {
|
|
78
|
+
return pages;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
pages.forEach((page) => {
|
|
82
|
+
page.relation.software.forEach((software) => {
|
|
83
|
+
if (selectedProviders && selectedProviders.includes(software.id)) {
|
|
84
|
+
pagesFiltered.push(page);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
page.relation.types.forEach((type) => {
|
|
88
|
+
if (selectedTypes && selectedTypes.includes(type)) {
|
|
89
|
+
pagesFiltered.push(page);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return pagesFiltered;
|
|
95
|
+
}
|
|
96
|
+
|
|
36
97
|
export function processCardsV2(module, pagesCloned, pagesMappedById) {
|
|
37
98
|
const pageType = module.cards_page_type;
|
|
38
99
|
const pageTemplateId = module.cards_page_type_id;
|
|
39
100
|
const sortType = module.cards_selector_filters_sort_by;
|
|
40
101
|
const cardSelector = module.cards_selector;
|
|
102
|
+
const moduleSelectedProviders =
|
|
103
|
+
module.cards_selector_filters && module.cards_selector_filters.providers;
|
|
104
|
+
const moduleSelectedCategories =
|
|
105
|
+
module.cards_selector_filters && module.cards_selector_filters.categories;
|
|
106
|
+
const moduleSelectedTypes = module.cards_selector_filters && module.cards_selector_filters.types;
|
|
41
107
|
module.items = [];
|
|
42
108
|
|
|
43
109
|
if (cardSelector === 'select_manually') {
|
|
@@ -56,52 +122,50 @@ export function processCardsV2(module, pagesCloned, pagesMappedById) {
|
|
|
56
122
|
pagesGroupedByTemplateId[pageType] = groupBy(pagesGroupedByType, 'template_id');
|
|
57
123
|
}
|
|
58
124
|
|
|
59
|
-
// Populate
|
|
60
|
-
const
|
|
125
|
+
// Populate pagesList if page type and template exists
|
|
126
|
+
const pagesList =
|
|
61
127
|
!pagesGroupedByTemplateId[pageType] || !pagesGroupedByTemplateId[pageType][pageTemplateId]
|
|
62
128
|
? []
|
|
63
129
|
: pagesGroupedByTemplateId[pageType][pageTemplateId];
|
|
64
130
|
|
|
65
131
|
// Check if there are pages before starting filtering
|
|
66
|
-
if (
|
|
132
|
+
if (pagesList.length > 0) {
|
|
67
133
|
const selectedAuthors = module.cards_selector_filters.page_authors;
|
|
68
134
|
const selectedCategories = module.cards_selector_filters.page_categories;
|
|
69
135
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const pagesMappedByAuthor = groupBy(pagesObject, 'author_id');
|
|
77
|
-
selectedAuthors.forEach((authorId) => {
|
|
78
|
-
pagesFilteredByAuthor = pagesFilteredByAuthor.concat(pagesMappedByAuthor[authorId] || []);
|
|
79
|
-
});
|
|
80
|
-
} else {
|
|
81
|
-
pagesFilteredByAuthor = pagesObject;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Filtering by Page Categories
|
|
85
|
-
// eslint-disable-next-line no-unused-expressions
|
|
86
|
-
selectedCategories
|
|
87
|
-
? selectedCategories.forEach((categoryId) => {
|
|
88
|
-
finalizedPageFilters = finalizedPageFilters.concat(
|
|
89
|
-
pagesFilteredByAuthor.filter((page) => page.categories.includes(categoryId))
|
|
90
|
-
);
|
|
91
|
-
})
|
|
92
|
-
: (finalizedPageFilters = pagesFilteredByAuthor);
|
|
136
|
+
const pagesFilteredByAuthor = filterPages(pagesList, selectedAuthors, 'author_id');
|
|
137
|
+
const pagesFilteredByAuthorAndCategory = filterPages(
|
|
138
|
+
pagesFilteredByAuthor,
|
|
139
|
+
selectedCategories,
|
|
140
|
+
'categories'
|
|
141
|
+
);
|
|
93
142
|
|
|
94
143
|
// Removing any duplicate pages in the final array (because pages may have more than one category)
|
|
95
|
-
const
|
|
96
|
-
const duplicateItem = filteredPages.find((page) => page.id === current.id);
|
|
97
|
-
if (!duplicateItem) {
|
|
98
|
-
return filteredPages.concat([current]);
|
|
99
|
-
}
|
|
100
|
-
return filteredPages;
|
|
101
|
-
}, []);
|
|
144
|
+
const filteredPages = removeDuplicates(pagesFilteredByAuthorAndCategory, 'id');
|
|
102
145
|
|
|
103
146
|
// Get limit, if not set 50 as default
|
|
104
147
|
const itemLimit = module.cards_selector_filters_limit || 50;
|
|
148
|
+
let finalizedFilteredPages = [];
|
|
149
|
+
|
|
150
|
+
switch (pageType) {
|
|
151
|
+
case 'game':
|
|
152
|
+
finalizedFilteredPages = filterGames(
|
|
153
|
+
filteredPages,
|
|
154
|
+
moduleSelectedCategories,
|
|
155
|
+
moduleSelectedProviders
|
|
156
|
+
);
|
|
157
|
+
break;
|
|
158
|
+
case 'operator':
|
|
159
|
+
finalizedFilteredPages = filterOperators(
|
|
160
|
+
filteredPages,
|
|
161
|
+
moduleSelectedProviders,
|
|
162
|
+
moduleSelectedTypes
|
|
163
|
+
);
|
|
164
|
+
break;
|
|
165
|
+
default:
|
|
166
|
+
finalizedFilteredPages = filteredPages;
|
|
167
|
+
}
|
|
168
|
+
const uniquePages = removeDuplicates(finalizedFilteredPages, 'id');
|
|
105
169
|
|
|
106
170
|
// Applying sorting
|
|
107
171
|
if (sortType === 'random') {
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { groupBy } from './common';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
filterPages,
|
|
4
|
+
processCardsV2,
|
|
5
|
+
filterGames,
|
|
6
|
+
filterOperators,
|
|
7
|
+
processBonus,
|
|
8
|
+
processTopListModule,
|
|
9
|
+
} from './modules';
|
|
3
10
|
import getPageDataList from '~tests/factories/pages/list.factory';
|
|
4
11
|
import {
|
|
5
12
|
getSampleCardsV2ModuleManual,
|
|
6
13
|
getSampleCardsV2Filtered,
|
|
7
14
|
} from '~tests/factories/modules/card.factory.js';
|
|
15
|
+
import { relationData, singleToplistData } from '../../../tests/factories/modules/toplist.factory';
|
|
8
16
|
|
|
9
17
|
describe('Modules Helper', () => {
|
|
10
18
|
test('Cards V2 Manual list', () => {
|
|
@@ -28,4 +36,61 @@ describe('Modules Helper', () => {
|
|
|
28
36
|
|
|
29
37
|
expect(moduleData.items).toHaveLength(4);
|
|
30
38
|
});
|
|
39
|
+
|
|
40
|
+
test('filterPages function', () => {
|
|
41
|
+
const pages = getPageDataList(3);
|
|
42
|
+
pages[0].author_id = 1;
|
|
43
|
+
const selectedFilters = [1];
|
|
44
|
+
|
|
45
|
+
const filteredPages = filterPages(pages, selectedFilters, 'author_id');
|
|
46
|
+
expect(filteredPages).toHaveLength(1);
|
|
47
|
+
expect(filteredPages[0].author_id).toEqual(1);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('Filter games function', () => {
|
|
51
|
+
let pages = getPageDataList(2);
|
|
52
|
+
let filtered = filterGames(pages, undefined, undefined);
|
|
53
|
+
expect(filtered).toHaveLength(2);
|
|
54
|
+
|
|
55
|
+
pages = getPageDataList(3);
|
|
56
|
+
pages[0].relation = { game_categories: [{ id: 2 }], game_provider: { id: 4 } };
|
|
57
|
+
pages[1].relation = { game_categories: [{ id: 3 }], game_provider: { id: 3 } };
|
|
58
|
+
pages[2].relation = { game_categories: [{ id: 5 }], game_provider: { id: 5 } };
|
|
59
|
+
filtered = filterGames(pages, [3], [4]);
|
|
60
|
+
|
|
61
|
+
expect(filtered).toHaveLength(2);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('Filter operators function', () => {
|
|
65
|
+
let pages = getPageDataList(3);
|
|
66
|
+
let filtered = filterOperators(pages, undefined, undefined);
|
|
67
|
+
expect(filtered).toHaveLength(3);
|
|
68
|
+
|
|
69
|
+
pages = getPageDataList(4);
|
|
70
|
+
pages[0].relation = { software: [{ id: 2 }], types: [1] };
|
|
71
|
+
pages[1].relation = { software: [{ id: 3 }], types: [2] };
|
|
72
|
+
pages[2].relation = { software: [{ id: 4 }], types: [3] };
|
|
73
|
+
pages[3].relation = { software: [{ id: 5 }], types: [4] };
|
|
74
|
+
|
|
75
|
+
filtered = filterOperators(pages, [2], [4]);
|
|
76
|
+
|
|
77
|
+
expect(filtered).toHaveLength(2);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('Process Bonus function', () => {
|
|
81
|
+
const module = { value: 1 };
|
|
82
|
+
const relations = { operator: { 1: { test: 'test' } } };
|
|
83
|
+
|
|
84
|
+
processBonus(module, relations);
|
|
85
|
+
expect(module.value.test).toEqual('test');
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('Process TopList module', () => {
|
|
89
|
+
processTopListModule(singleToplistData, relationData);
|
|
90
|
+
|
|
91
|
+
expect(singleToplistData.items[0].items[0].rating_casino).toEqual('4');
|
|
92
|
+
expect(singleToplistData.items[0].items[0].selling_points).toHaveLength(2);
|
|
93
|
+
expect(singleToplistData.items[0].items[0].short_name).toEqual('slotum');
|
|
94
|
+
expect(singleToplistData.items[0].items[0].bonus.deposit_methods).toHaveLength(1);
|
|
95
|
+
});
|
|
31
96
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
3
|
+
import { graphql, useStaticQuery } from 'gatsby';
|
|
4
4
|
import { GatsbyImage } from 'gatsby-plugin-image';
|
|
5
5
|
|
|
6
6
|
export const PureImage = ({
|
|
@@ -11,7 +11,7 @@ export const PureImage = ({
|
|
|
11
11
|
width = '100%',
|
|
12
12
|
data,
|
|
13
13
|
}) => {
|
|
14
|
-
const image = data.images.edges.find((n) => n.node.relativePath.includes(filename));
|
|
14
|
+
const image = data && data.images.edges.find((n) => n.node.relativePath.includes(filename));
|
|
15
15
|
if (!image) {
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
@@ -26,26 +26,25 @@ export const PureImage = ({
|
|
|
26
26
|
);
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
export const Image = (props) =>
|
|
30
|
-
|
|
31
|
-
query
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
gatsbyImageData(layout: FULL_WIDTH)
|
|
40
|
-
}
|
|
29
|
+
export const Image = (props) => {
|
|
30
|
+
const data = useStaticQuery(graphql`
|
|
31
|
+
query {
|
|
32
|
+
images: allFile(filter: { extension: { nin: ["svg", "gif", ".gitkeep"] } }) {
|
|
33
|
+
edges {
|
|
34
|
+
node {
|
|
35
|
+
relativePath
|
|
36
|
+
name
|
|
37
|
+
childImageSharp {
|
|
38
|
+
gatsbyImageData(layout: FULL_WIDTH)
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
}
|
|
44
|
+
`);
|
|
45
|
+
|
|
46
|
+
return <PureImage {...props} data={data} />;
|
|
47
|
+
};
|
|
49
48
|
|
|
50
49
|
PureImage.propTypes = {
|
|
51
50
|
filename: PropTypes.string,
|
|
@@ -104,6 +104,7 @@ export const multiToplistData = {
|
|
|
104
104
|
name: 'Bet365',
|
|
105
105
|
type: 'casino',
|
|
106
106
|
short_name: 'bet365',
|
|
107
|
+
operator_id: 6342,
|
|
107
108
|
logo_url: 'image-63.png',
|
|
108
109
|
rating: '3',
|
|
109
110
|
review_link: '/bet365',
|
|
@@ -431,6 +432,10 @@ export const singleToplistData = {
|
|
|
431
432
|
{
|
|
432
433
|
name: 'Slotum',
|
|
433
434
|
type: 'casino',
|
|
435
|
+
operator_id: 6342,
|
|
436
|
+
bonus: {
|
|
437
|
+
deposit_methods: ['test'],
|
|
438
|
+
},
|
|
434
439
|
short_name: 'slotum',
|
|
435
440
|
logo_url: 'slotum-casino-logo-transparentpng6b10407566-original.png',
|
|
436
441
|
rating: '4',
|
|
@@ -453,6 +458,10 @@ export const singleToplistData = {
|
|
|
453
458
|
{
|
|
454
459
|
name: 'Rizk',
|
|
455
460
|
type: 'casino',
|
|
461
|
+
operator_id: 6342,
|
|
462
|
+
bonus: {
|
|
463
|
+
deposit_methods: [],
|
|
464
|
+
},
|
|
456
465
|
short_name: 'rizk',
|
|
457
466
|
logo_url: 'rizk-logopng7ed316ac19-original.png',
|
|
458
467
|
rating: '4',
|
|
@@ -475,6 +484,10 @@ export const singleToplistData = {
|
|
|
475
484
|
{
|
|
476
485
|
name: 'Casoola',
|
|
477
486
|
type: 'casino',
|
|
487
|
+
operator_id: 6342,
|
|
488
|
+
bonus: {
|
|
489
|
+
deposit_methods: [],
|
|
490
|
+
},
|
|
478
491
|
short_name: 'casoola',
|
|
479
492
|
logo_url: 'casoola-logopng381ab5c04f-original.png',
|
|
480
493
|
rating: '3',
|
|
@@ -492,6 +505,10 @@ export const singleToplistData = {
|
|
|
492
505
|
{
|
|
493
506
|
name: 'Bet365',
|
|
494
507
|
type: 'casino',
|
|
508
|
+
operator_id: 6342,
|
|
509
|
+
bonus: {
|
|
510
|
+
deposit_methods: [],
|
|
511
|
+
},
|
|
495
512
|
short_name: 'bet365',
|
|
496
513
|
logo_url: 'image-63.png',
|
|
497
514
|
rating: '3',
|
|
@@ -512,6 +529,10 @@ export const singleToplistData = {
|
|
|
512
529
|
{
|
|
513
530
|
name: 'Captain Spins',
|
|
514
531
|
type: 'casino',
|
|
532
|
+
operator_id: 6342,
|
|
533
|
+
bonus: {
|
|
534
|
+
deposit_methods: [],
|
|
535
|
+
},
|
|
515
536
|
short_name: 'captain-spins',
|
|
516
537
|
logo_url: 'captain-spins-logopng07b24ceb59-original.png',
|
|
517
538
|
rating: '4',
|
|
@@ -532,6 +553,10 @@ export const singleToplistData = {
|
|
|
532
553
|
{
|
|
533
554
|
name: 'Casino Gods',
|
|
534
555
|
type: 'casino',
|
|
556
|
+
operator_id: 6342,
|
|
557
|
+
bonus: {
|
|
558
|
+
deposit_methods: [],
|
|
559
|
+
},
|
|
535
560
|
short_name: 'casino-gods',
|
|
536
561
|
logo_url: 'casino-gods-logopng3bfc0d51-original.png',
|
|
537
562
|
rating: '3',
|
|
@@ -552,6 +577,10 @@ export const singleToplistData = {
|
|
|
552
577
|
{
|
|
553
578
|
name: 'Jinni Lotto',
|
|
554
579
|
type: 'casino',
|
|
580
|
+
operator_id: 6342,
|
|
581
|
+
bonus: {
|
|
582
|
+
deposit_methods: [],
|
|
583
|
+
},
|
|
555
584
|
short_name: 'jinni-lotto',
|
|
556
585
|
logo_url: 'jinnilotto-logopng464964d6b0-original.png',
|
|
557
586
|
rating: '4',
|
|
@@ -572,6 +601,10 @@ export const singleToplistData = {
|
|
|
572
601
|
{
|
|
573
602
|
name: 'Betfair',
|
|
574
603
|
type: 'casino',
|
|
604
|
+
operator_id: 6342,
|
|
605
|
+
bonus: {
|
|
606
|
+
deposit_methods: [],
|
|
607
|
+
},
|
|
575
608
|
short_name: 'betfair',
|
|
576
609
|
logo_url: '5aedeb23bb-original.png',
|
|
577
610
|
rating: '5',
|
|
@@ -592,6 +625,10 @@ export const singleToplistData = {
|
|
|
592
625
|
{
|
|
593
626
|
name: 'Casoola',
|
|
594
627
|
type: 'casino',
|
|
628
|
+
operator_id: 6342,
|
|
629
|
+
bonus: {
|
|
630
|
+
deposit_methods: [],
|
|
631
|
+
},
|
|
595
632
|
short_name: 'casoola',
|
|
596
633
|
logo_url: 'casoola-logopng381ab5c04f-original.png',
|
|
597
634
|
rating: '3',
|
|
@@ -612,6 +649,10 @@ export const singleToplistData = {
|
|
|
612
649
|
{
|
|
613
650
|
name: 'Bet365',
|
|
614
651
|
type: 'casino',
|
|
652
|
+
operator_id: 6342,
|
|
653
|
+
bonus: {
|
|
654
|
+
deposit_methods: [],
|
|
655
|
+
},
|
|
615
656
|
short_name: 'bet365',
|
|
616
657
|
logo_url: 'image-63.png',
|
|
617
658
|
rating: '3',
|
|
@@ -632,6 +673,10 @@ export const singleToplistData = {
|
|
|
632
673
|
{
|
|
633
674
|
name: 'Captain Spins',
|
|
634
675
|
type: 'casino',
|
|
676
|
+
operator_id: 6342,
|
|
677
|
+
bonus: {
|
|
678
|
+
deposit_methods: [],
|
|
679
|
+
},
|
|
635
680
|
short_name: 'captain-spins',
|
|
636
681
|
logo_url: 'captain-spins-logopng07b24ceb59-original.png',
|
|
637
682
|
rating: '4',
|
|
@@ -652,6 +697,10 @@ export const singleToplistData = {
|
|
|
652
697
|
{
|
|
653
698
|
name: 'Slotum',
|
|
654
699
|
type: 'casino',
|
|
700
|
+
operator_id: 6342,
|
|
701
|
+
bonus: {
|
|
702
|
+
deposit_methods: [],
|
|
703
|
+
},
|
|
655
704
|
short_name: 'slotum',
|
|
656
705
|
logo_url: 'slotum-casino-logo-transparentpng6b10407566-original.png',
|
|
657
706
|
rating: '4',
|
|
@@ -672,6 +721,10 @@ export const singleToplistData = {
|
|
|
672
721
|
{
|
|
673
722
|
name: 'Casoola',
|
|
674
723
|
type: 'casino',
|
|
724
|
+
operator_id: 6342,
|
|
725
|
+
bonus: {
|
|
726
|
+
deposit_methods: [],
|
|
727
|
+
},
|
|
675
728
|
short_name: 'casoola',
|
|
676
729
|
logo_url: 'casoola-logopng381ab5c04f-original.png',
|
|
677
730
|
rating: '3',
|
|
@@ -700,3 +753,70 @@ export const singleToplistData = {
|
|
|
700
753
|
},
|
|
701
754
|
],
|
|
702
755
|
};
|
|
756
|
+
|
|
757
|
+
export const relationData = {
|
|
758
|
+
operator: {
|
|
759
|
+
6342: {
|
|
760
|
+
id: 6342,
|
|
761
|
+
market_id: 25,
|
|
762
|
+
operator_id: 319,
|
|
763
|
+
review_link: 'http://www.irishluck.ie/dunder-casino-review/',
|
|
764
|
+
rating_casino: '4',
|
|
765
|
+
rating_games: '4.3',
|
|
766
|
+
rating_bonuses: '4.3',
|
|
767
|
+
rating_customer: '4.5',
|
|
768
|
+
rating_payout: '',
|
|
769
|
+
rating: '4.3',
|
|
770
|
+
selling_points: [],
|
|
771
|
+
per_site_enabled: true,
|
|
772
|
+
status: 'active',
|
|
773
|
+
date_last_modified: '2020-10-06',
|
|
774
|
+
links: {
|
|
775
|
+
main: 'https://media.dunderaffiliates.com/redirect.aspx?pid=630524&bid=1477',
|
|
776
|
+
'PPC Fallback': 'https://media.dunderaffiliates.com/redirect.aspx?pid=740444&bid=1803',
|
|
777
|
+
},
|
|
778
|
+
custom_links: [],
|
|
779
|
+
owner: 'Burstit Limited',
|
|
780
|
+
types: ['casino'],
|
|
781
|
+
type: 'casino',
|
|
782
|
+
deposit_wagering: '0x',
|
|
783
|
+
support_types: 'Live chat, Email, Vip Support',
|
|
784
|
+
bonus: {
|
|
785
|
+
deposit_methods: ['asd', 'asd'],
|
|
786
|
+
},
|
|
787
|
+
software: [
|
|
788
|
+
{
|
|
789
|
+
id: 2,
|
|
790
|
+
name: '2by2 Gaming',
|
|
791
|
+
short_name: '2_by_2_gaming',
|
|
792
|
+
logo_asset_id: 10737,
|
|
793
|
+
games_count: 1,
|
|
794
|
+
updated_at: null,
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
id: 5,
|
|
798
|
+
name: 'Amaya',
|
|
799
|
+
short_name: 'amaya',
|
|
800
|
+
logo_asset_id: 0,
|
|
801
|
+
games_count: 0,
|
|
802
|
+
updated_at: null,
|
|
803
|
+
},
|
|
804
|
+
],
|
|
805
|
+
one_liners: {
|
|
806
|
+
main: {
|
|
807
|
+
one_liner: '€100 Welcome bonus+ 120 Free Spins',
|
|
808
|
+
start_date: null,
|
|
809
|
+
end_date: null,
|
|
810
|
+
categories: [],
|
|
811
|
+
percentage: '',
|
|
812
|
+
amount: '',
|
|
813
|
+
freespins: '',
|
|
814
|
+
freemoney: '',
|
|
815
|
+
freespins_nodeposit_amount: '',
|
|
816
|
+
freespins_nodeposit_bonuscode: '',
|
|
817
|
+
freespins_nodeposit_games: '',
|
|
818
|
+
},
|
|
819
|
+
},
|
|
820
|
+
},
|
|
821
|
+
},
|
|
822
|
+
};
|