gatsby-core-theme 44.5.4 → 44.6.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 CHANGED
@@ -1,3 +1,24 @@
1
+ # [44.6.0](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.5.4...v44.6.0) (2025-11-05)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add tests ([d4a5beb](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/d4a5beb41c0ca2455bd6a6098392ff895463363c))
7
+ * create a function to be used by both prefiled module use filters and normal cards v2 use filters ([644ab6b](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/644ab6b2a767ac2a8229137c3d7f0485a483f1f8))
8
+ * fix conflicts ([2fc5b12](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/2fc5b120fb90cb00085fa9d4024191edcd4dc049))
9
+ * processCardsv2 logic to include a case for prefilled modules when use filters is selected ([e233b24](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/e233b247e4ff9011394ad1faf83c010a1f755de8))
10
+ * refactor my MR on prefilled to make dry ([f49718d](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/f49718d36ef34d1beafac764524241a1bb1ec4d4))
11
+ * resolve conflicts ([565d812](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/565d8120f6c1010b55c08c52c5433a466ab08a90))
12
+
13
+
14
+ * Merge branch 'EN-203/image-text-spotlights' into 'master' ([0e10e81](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/0e10e81873e5bd3bafe9f9b524c9aa436ebafda7))
15
+ * Merge branch 'en-104-prefilled-card-module' into 'master' ([065b470](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/065b4707594e1956ef4830bbb5402022c88b91ef))
16
+
17
+
18
+ ### Features
19
+
20
+ * spotlights module template ([307d296](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/307d296b473b73c7d180845cb3eef8be5ed33622))
21
+
1
22
  ## [44.5.4](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.5.3...v44.5.4) (2025-10-31)
2
23
 
3
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "44.5.4",
3
+ "version": "44.6.0",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "author": "",
6
6
  "license": "ISC",
@@ -80,6 +80,11 @@ const Modules = ({ module, page, pageContext, modulePosition }) => {
80
80
  import("~molecules/spotlights_v2/image-text/template-four")
81
81
  );
82
82
  }
83
+ if (module?.style === "template_five") {
84
+ return lazy(() =>
85
+ import("~molecules/spotlights_v2/image-text/template-five")
86
+ );
87
+ }
83
88
  return lazy(() =>
84
89
  import("~molecules/spotlights_v2/image-text/template-one")
85
90
  );
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import keygen from '~helpers/keygen';
4
+ import styles from './template-five.module.scss';
5
+ import Item from './item';
6
+
7
+ export default function TemplateOne({
8
+ module,
9
+ scrollableContent = false,
10
+ width = 104,
11
+ height = 104,
12
+ modulePosition
13
+ }) {
14
+ const { items } = module;
15
+ return (
16
+ <div className={styles?.spotlightsImage || ''}>
17
+ {
18
+ // eslint-disable-next-line react/prop-types
19
+ items?.map((res,index) => (
20
+ <Item
21
+ key={keygen()}
22
+ item={res}
23
+ scrollableContent={scrollableContent}
24
+ width={width}
25
+ height={height}
26
+ modulePosition={modulePosition}
27
+ moduleName={module.name}
28
+ index={index+1}
29
+ />
30
+ ))
31
+ }
32
+ </div>
33
+ );
34
+ }
35
+
36
+ TemplateOne.propTypes = {
37
+ module: PropTypes.shape({
38
+ items: PropTypes.arrayOf(PropTypes.shape({})),
39
+ name: PropTypes.string,
40
+ }).isRequired,
41
+ scrollableContent: PropTypes.bool,
42
+ width: PropTypes.number,
43
+ height: PropTypes.number,
44
+ modulePosition: PropTypes.number,
45
+ };
@@ -0,0 +1,64 @@
1
+ /* eslint-disable jsx-a11y/click-events-have-key-events */
2
+ /* eslint-disable jsx-a11y/no-static-element-interactions */
3
+ import React from "react";
4
+ import PropTypes from "prop-types";
5
+ import LazyImage from "~hooks/lazy-image";
6
+ import {
7
+ imagePrettyUrl,
8
+ } from "~helpers/getters.mjs";
9
+ import { getAltText } from "~helpers/image";
10
+ import styles from "./style.module.scss";
11
+
12
+ export default function TemplateOne({
13
+ item,
14
+ scrollableContent = false,
15
+ width = 240,
16
+ height = 240,
17
+ index
18
+ }) {
19
+ const TitleTag = item?.title_tag || "label";
20
+
21
+ return (
22
+ <div className={styles.item}>
23
+ <div>
24
+ <span className={styles.number}>{index}</span>
25
+ </div>
26
+ <div className={styles.content}>
27
+ {item?.label && <TitleTag>{item?.label}</TitleTag>}
28
+ {item?.text && (
29
+ <div
30
+ tabIndex={`${scrollableContent ? 0 : -1}`}
31
+ className={`${styles.desc} ${
32
+ scrollableContent ? styles.scroll : ""
33
+ }`}
34
+ dangerouslySetInnerHTML={{ __html: item?.text }}
35
+ />
36
+ )}
37
+ </div>
38
+ {item?.image && (
39
+ <LazyImage
40
+ width={width}
41
+ height={height}
42
+ src={imagePrettyUrl(item?.image, width, height)}
43
+ alt={getAltText(item?.image_object, item?.label)}
44
+ />
45
+ )}
46
+ </div>
47
+ );
48
+ }
49
+
50
+ TemplateOne.propTypes = {
51
+ item: PropTypes.shape({
52
+ title_tag: PropTypes.string,
53
+ image: PropTypes.string,
54
+ label: PropTypes.string,
55
+ text: PropTypes.string,
56
+ image_object: PropTypes.shape({
57
+ alt: PropTypes.string,
58
+ }),
59
+ }).isRequired,
60
+ scrollableContent: PropTypes.bool,
61
+ width: PropTypes.number,
62
+ height: PropTypes.number,
63
+ index: PropTypes.number
64
+ };
@@ -0,0 +1,196 @@
1
+ .content {
2
+ @include flex-direction(column);
3
+ @include flex-align(center, center);
4
+
5
+ gap: 1.6rem;
6
+ align-items: flex-start;
7
+
8
+
9
+ > label {
10
+ font-size: 2.4rem;
11
+ font-weight: 600;
12
+ line-height: 3.2rem;
13
+ color: #1B1B1C;
14
+
15
+ @include min(tablet) {
16
+ grid-column: 2;
17
+ }
18
+ }
19
+
20
+ > h2,
21
+ h3,
22
+ h4 {
23
+ font-size: 2.4rem;
24
+ font-weight: 600;
25
+ line-height: 3.2rem;
26
+ color: #1B1B1C;
27
+
28
+ @include min(tablet) {
29
+ grid-column: 2;
30
+ }
31
+ }
32
+ }
33
+
34
+ .subtitle {
35
+ color: #64646d;
36
+ text-align: center;
37
+ font-size: 1.4rem;
38
+ font-style: normal;
39
+ font-weight: 700;
40
+ line-height: 2.2rem;
41
+ margin-bottom: 1.6rem;
42
+
43
+ @include min(tablet) {
44
+ grid-column: 2;
45
+ }
46
+ }
47
+
48
+ .item {
49
+ width: 100%;
50
+ height: 100%;
51
+ padding-top: 2.4rem;
52
+ padding-bottom: 2.4rem;
53
+ gap: 1.6rem;
54
+
55
+ @include flex-direction(column);
56
+ @include flex-align(start, space-between);
57
+
58
+ border-bottom: 2px solid #D63B54;
59
+
60
+ @include min(tablet) {
61
+ padding-top: 3.2rem;
62
+ padding-bottom: 3.2rem;
63
+ flex-direction: row;
64
+ }
65
+
66
+ > a {
67
+ height: 5.6rem;
68
+ width: 100%;
69
+ }
70
+
71
+ > img {
72
+ width: 34rem;
73
+ height: 34rem;
74
+ object-fit: cover;
75
+ border-radius: .8rem;
76
+
77
+ @include min(tablet) {
78
+ grid-row: 1 / span 2;
79
+ grid-column: 1;
80
+ width: 24rem;
81
+ height: 24rem;
82
+ }
83
+ }
84
+ }
85
+
86
+ .desc {
87
+ color: var(--spotlight-template-one-desc-image-text-mode, #515156);
88
+ text-align: left;
89
+ font-size: 1.6rem;
90
+ font-style: normal;
91
+ font-weight: 400;
92
+ line-height: 2.6rem;
93
+
94
+ @include min(tablet) {
95
+ grid-column: 2;
96
+ }
97
+ }
98
+
99
+ .readMore {
100
+ height: 13.5rem;
101
+ overflow: hidden;
102
+ }
103
+
104
+ .scroll {
105
+ max-height: 16.2rem;
106
+ overflow-y: auto;
107
+ padding-right: 1.6rem;
108
+
109
+ &::-webkit-scrollbar {
110
+ width: 0.6rem;
111
+ }
112
+
113
+ &::-webkit-scrollbar-track {
114
+ background: #c4c4c4;
115
+ border-radius: 0.5rem;
116
+ }
117
+
118
+ &::-webkit-scrollbar-thumb {
119
+ background: #515156;
120
+ border-radius: 0.5rem;
121
+ }
122
+
123
+ &::-webkit-scrollbar-thumb:hover {
124
+ background: #555;
125
+ }
126
+ }
127
+
128
+ .readMoreBtn {
129
+ @include flex-direction(row);
130
+ @include flex-align(center, start);
131
+
132
+ width: 100%;
133
+ color: #262629;
134
+ font-size: 1.6rem;
135
+ font-style: normal;
136
+ font-weight: 600;
137
+ line-height: 2.7rem;
138
+ cursor: pointer;
139
+
140
+ > svg {
141
+ margin-left: 0.4rem;
142
+ }
143
+
144
+ @include min(tablet) {
145
+ grid-column: 2;
146
+ }
147
+ }
148
+
149
+ .topSection{
150
+ display: flex;
151
+ align-items: flex-start;
152
+ justify-content: flex-start;
153
+
154
+ > h2,
155
+ h3,
156
+ h4 {
157
+ font-size: 2.4rem;
158
+ font-weight: 600;
159
+ line-height: 3.2rem;
160
+ color: #1B1B1C;
161
+
162
+ @include min(tablet) {
163
+ grid-column: 2;
164
+ }
165
+ }
166
+
167
+ span{
168
+ margin-right: 1rem;
169
+ background-color: #D63B54;
170
+ width: 3.2rem;
171
+ height: 3.2rem;
172
+ border-radius: 100%;
173
+ font-size: 1.4rem;
174
+ line-height: 2.2rem;
175
+ font-weight: 500;
176
+ color: #FDFEFD;
177
+ display: flex;
178
+ justify-content: center;
179
+ align-items: center;
180
+ margin-left: -4.3rem;
181
+ }
182
+ }
183
+
184
+ .number{
185
+ background-color: #D63B54;
186
+ width: 3.2rem;
187
+ height: 3.2rem;
188
+ border-radius: 100%;
189
+ font-size: 1.4rem;
190
+ line-height: 2.2rem;
191
+ font-weight: 500;
192
+ color: #FDFEFD;
193
+ display: flex;
194
+ justify-content: center;
195
+ align-items: center;
196
+ }
@@ -0,0 +1,9 @@
1
+ .spotlightsImage {
2
+ max-width: var(--main-container-max);
3
+ margin: 0 auto;
4
+
5
+ @include flex-direction(column);
6
+ @include flex-align(center, center);
7
+
8
+ gap: 1.6rem;
9
+ }
@@ -0,0 +1,94 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ import React from 'react';
3
+ import {
4
+ Title,
5
+ Description,
6
+ Primary,
7
+ PRIMARY_STORY,
8
+ ArgsTable,
9
+ } from '@storybook/addon-docs/blocks';
10
+ import TemplateOne from '.';
11
+
12
+ export default {
13
+ title: 'Theme/Modules/Spotlight/Image Text/Template Five',
14
+ component: TemplateOne,
15
+ argTypes: {
16
+ buttonType: {
17
+ name: 'buttonType',
18
+ defaultValue: 'secondary',
19
+ options: ['primary', 'secondary', 'tertiary'],
20
+ control: { type: 'radio' },
21
+ },
22
+ buttonSize: {
23
+ name: 'buttonType',
24
+ defaultValue: 'm',
25
+ options: ['xs', 's', 'm', 'l', 'xl', 'noSize'],
26
+ control: { type: 'radio' },
27
+ },
28
+ },
29
+ parameters: {
30
+ docs: {
31
+ description: {
32
+ component: 'A component that shows a list of pros and cons and corresponding icons.',
33
+ },
34
+ page: () => (
35
+ <>
36
+ <Title />
37
+ <Description />
38
+ <Primary />
39
+ <ArgsTable story={PRIMARY_STORY} />
40
+ </>
41
+ ),
42
+ },
43
+ },
44
+ };
45
+
46
+ const Template = (args) => <TemplateOne {...args} />;
47
+
48
+ export const Default = Template.bind({});
49
+ Default.args = {
50
+ module: {
51
+ mode: 'image_text',
52
+ read_more_text: '',
53
+ show_read_more: '1',
54
+ items: [
55
+ {
56
+ image: `1702045256/xl.png`,
57
+ label: `Javier A. Pernia`,
58
+ link: {
59
+ title: null,
60
+ type: 'internal',
61
+ value: `/rizk`,
62
+ },
63
+ link_text: 'Read Review',
64
+ subtitle: 'Senior Content Writer',
65
+ text: `<p>Lorem ipsum dolor sit amet consectetur. Diam justo eu tellus morbi amet suspendisse purus tincidunt. Fermentum with risus felis feugiat scelerisque in convallis id cras. Varius lacus id lacus hendrerit commodo orci loredio dignissim massa mauris massa pellentesque et magna lectus duis. Rhoncus eros enim egestas integer eu duis ullamcorper. Magna dictum suspendisse habitasse massa. Odio viverra sit nisl duis nisl sit. Quam ut tincidunt dui lorem pretium commodo aliquam accumsan. Sagittis ultrices est vitae habitant eget morbi. Eu non ipsum pretium enim eleifend quam ut. At tortor in ut sed ultrices suspendisse bibendum nunc. In odio volutpat scelerisque gravida egestas ut turpis. Ut facilisi massa elit maecenas amet volutpat quis eu.</p>`,
66
+ },
67
+ {
68
+ image: `1702045256/xl.png`,
69
+ label: `Javier A. Pernia`,
70
+ subtitle: 'Senior Content Writer',
71
+ link: {
72
+ title: null,
73
+ type: 'internal',
74
+ value: `/rizk`,
75
+ },
76
+ link_text: 'Read Review',
77
+ text: `<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ullamcorper orci a, nec lacus, viverra. Fusce pellentesque eget vitae, ac nibh sem in neque sagittis. Dapibus ornare egestas sagittis massa arcu est arcu fermentum.</p>`,
78
+ },
79
+ {
80
+ image: `1702045256/xl.png`,
81
+ subtitle: 'Senior Content Writer',
82
+ label: `Javier A. Pernia`,
83
+ link: {
84
+ title: null,
85
+ type: 'internal',
86
+ value: `/rizk`,
87
+ },
88
+ link_text: 'Read Review',
89
+ text: `<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ullamcorper orci a, nec lacus, viverra. Fusce pellentesque eget vitae, ac nibh sem in neque sagittis. Dapibus ornare egestas sagittis massa arcu est arcu fermentum.</p>`,
90
+ },
91
+ ],
92
+ },
93
+ scrollableContent: false,
94
+ };
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import '@testing-library/jest-dom/extend-expect';
4
+ import { getSpotlightItems } from '~tests/factories/modules/spotlights.factory';
5
+ import TemplateFive from '.';
6
+
7
+ test('Image-text mode', () => {
8
+ const { container } = render(<TemplateFive module={getSpotlightItems(6, 'image')} />);
9
+
10
+ const img = screen.getByAltText('label 6');
11
+ expect(img).toBeInTheDocument();
12
+
13
+ const paragraphs = container.querySelectorAll('p');
14
+ expect(paragraphs.length).toBeGreaterThan(0);
15
+
16
+ const labels = container.querySelectorAll('label');
17
+ expect(labels.length).toBeGreaterThan(0);
18
+ });
@@ -219,6 +219,7 @@ export function processSections(
219
219
  data,
220
220
  toplists,
221
221
  content,
222
+ prefilledMarketModules,
222
223
  previewPageID
223
224
  );
224
225
  sections[sectionKey].modules[key] = module;
@@ -119,24 +119,132 @@ export function filterOperators(pages, selectedProviders, selectedTypes) {
119
119
  return filterInactiveOperators(pagesFiltered);
120
120
  }
121
121
 
122
+ export function buildCardItems({
123
+ module,
124
+ pagesCloned,
125
+ pagesMappedById,
126
+ cardType,
127
+ pageTemplateId,
128
+ sortType,
129
+ market,
130
+ content,
131
+ pageId,
132
+ selectedAuthors,
133
+ selectedReviewer,
134
+ selectedCategories,
135
+ selectedProviders,
136
+ selectedTypes,
137
+ limit = 50,
138
+ }) {
139
+ const allFilters = [
140
+ cardType,
141
+ pageTemplateId,
142
+ selectedAuthors,
143
+ selectedReviewer,
144
+ selectedCategories,
145
+ selectedProviders,
146
+ selectedTypes,
147
+ ];
148
+
149
+ const u8 = new Uint8Array(allFilters);
150
+ const b64 = Buffer.from(u8).toString("base64");
151
+
152
+ let pagesList = [];
153
+ if (cardType) {
154
+ const pagesGroupedByType = pagesCloned[cardType];
155
+ if (!pagesGroupedByTemplateId[`${cardType}_${market}`]) {
156
+ pagesGroupedByTemplateId[`${cardType}_${market}`] = groupBy(
157
+ pagesGroupedByType,
158
+ "template_id"
159
+ );
160
+ }
161
+ pagesList =
162
+ pagesGroupedByTemplateId[`${cardType}_${market}`][pageTemplateId] || [];
163
+ } else {
164
+ pagesList = Object.values(pagesMappedById);
165
+ }
166
+
167
+ if (pagesList.length > 0) {
168
+ if (!cardItems[b64]) {
169
+ let filteredPages = filterPages(pagesList, selectedAuthors, "author_id");
170
+ filteredPages = filterPages(
171
+ filteredPages,
172
+ selectedReviewer,
173
+ "reviewer_id"
174
+ );
175
+ filteredPages = filterPages(
176
+ filteredPages,
177
+ selectedCategories,
178
+ "categoryIds",
179
+ pageId
180
+ );
181
+ filteredPages = removeDuplicates(filteredPages, "id");
182
+
183
+ let finalizedFilteredPages = [];
184
+ switch (cardType) {
185
+ case "game":
186
+ finalizedFilteredPages = filterGames(
187
+ filteredPages,
188
+ selectedCategories,
189
+ selectedProviders
190
+ );
191
+ break;
192
+ case "operator":
193
+ finalizedFilteredPages = filterOperators(
194
+ filteredPages,
195
+ selectedProviders,
196
+ selectedTypes
197
+ );
198
+ break;
199
+ case "event":
200
+ finalizedFilteredPages = filterEvents(filteredPages);
201
+ break;
202
+ default:
203
+ finalizedFilteredPages = filteredPages;
204
+ }
205
+
206
+ const uniquePages = removeCurrentPage(
207
+ removeDuplicates(finalizedFilteredPages, "id"),
208
+ pageId
209
+ );
210
+ cardItems[b64] = uniquePages;
211
+ }
212
+
213
+ const items = cardItems[b64];
214
+ if (sortType === "random") {
215
+ module.items = sampleSize(items, limit);
216
+ } else if (sortType === "latest") {
217
+ items.sort((a, b) => (a.created_at > b.created_at ? -1 : 1));
218
+ module.items = items.slice(0, limit);
219
+ } else if (sortType === "alphabetical") {
220
+ items.sort((a, b) => a.title.localeCompare(b.title));
221
+ module.items = items.slice(0, limit);
222
+ } else {
223
+ module.items = items.slice(0, limit);
224
+ }
225
+
226
+ module.items = module.items.map((item) =>
227
+ clonePageForCards(cloneDeep(item), module.style, content)
228
+ );
229
+ }
230
+ }
231
+
122
232
  export function processCardsV2(
123
233
  module,
124
234
  pagesCloned,
125
235
  pagesMappedById,
126
236
  pageId,
127
- content
237
+ content,
238
+ prefilledMarketModules = {}
128
239
  ) {
129
- const cardType = module.cards_page_type;
130
- const pageTemplateId = module.cards_page_type_id;
131
- const sortType = module.cards_selector_filters_sort_by;
132
- const cardSelector = module.cards_selector;
240
+ const prefilled =
241
+ prefilledMarketModules[module.module_value_id] ||
242
+ prefilledMarketModules[module.value_id];
243
+
244
+ const cardType = module?.cards_page_type || prefilled?.cards_page_type;
245
+
246
+ const cardSelector = module?.cards_selector;
133
247
  const styleName = module.style;
134
- const moduleSelectedProviders =
135
- module.cards_selector_filters && module.cards_selector_filters.providers;
136
- const moduleSelectedCategories =
137
- module.cards_selector_filters && module.cards_selector_filters.categories;
138
- const moduleSelectedTypes =
139
- module.cards_selector_filters && module.cards_selector_filters.types;
140
248
 
141
249
  const market = pagesMappedById[pageId] ? pagesMappedById[pageId].market : "";
142
250
 
@@ -155,131 +263,53 @@ export function processCardsV2(
155
263
  if (cardType === "operator") {
156
264
  module.items = filterInactiveOperators(module.items);
157
265
  }
158
- } else if (cardSelector === "use_filters") {
159
- let pagesList = [];
160
- const selectedAuthors = module.cards_selector_filters.page_authors;
161
- const selectedReviewer = module.cards_selector_filters.page_reviewer;
162
- const selectedCategories = module.cards_selector_filters.page_categories;
163
-
164
- const allFilters = [
266
+ } else if (
267
+ cardSelector === "use_filters" ||
268
+ (prefilled && prefilled.cards_selector === "use_filters")
269
+ ) {
270
+ const filters = module?.cards_selector_filters || {};
271
+ const prefilledFilters = prefilled?.cards_selector_filters || {};
272
+ const { page_authors, page_reviewer, page_categories } = filters;
273
+ const pageTemplateId =
274
+ module?.cards_page_type_id || prefilled?.cards_page_type_id;
275
+
276
+ const sortType =
277
+ module?.cards_selector_filters_sort_by ||
278
+ prefilled?.cards_selector_filters_sort_by;
279
+
280
+ const moduleSelectedProviders =
281
+ (module?.cards_selector_filters &&
282
+ module?.cards_selector_filters.providers) ||
283
+ prefilledFilters?.providers;
284
+
285
+ const moduleSelectedTypes =
286
+ (module?.cards_selector_filters && module?.cards_selector_filters.types) ||
287
+ prefilledFilters?.types;
288
+
289
+ const limit =
290
+ module?.cards_selector_filters_limit ||
291
+ prefilled?.cards_selector_filters_limit ||
292
+ 50;
293
+
294
+ buildCardItems({
295
+ module,
296
+ pagesCloned,
297
+ pagesMappedById,
298
+ pagesGroupedByTemplateId,
299
+ cardItems,
165
300
  cardType,
166
301
  pageTemplateId,
167
- selectedAuthors,
168
- selectedReviewer,
169
- selectedCategories,
170
- moduleSelectedProviders,
171
- moduleSelectedCategories,
172
- moduleSelectedTypes,
173
- ];
174
-
175
- const u8 = new Uint8Array(allFilters);
176
- const b64 = Buffer.from(u8).toString("base64");
177
-
178
- if (cardType) {
179
- // Get all pages by the selected page type
180
- const pagesGroupedByType = pagesCloned[cardType];
181
-
182
- // Grouping pages by template ID
183
- if (!pagesGroupedByTemplateId[`${cardType}_${market}`]) {
184
- pagesGroupedByTemplateId[`${cardType}_${market}`] = groupBy(
185
- pagesGroupedByType,
186
- "template_id"
187
- );
188
- }
189
-
190
- // Populate pagesList if page type and template exists
191
- pagesList =
192
- !pagesGroupedByTemplateId[`${cardType}_${market}`] ||
193
- !pagesGroupedByTemplateId[`${cardType}_${market}`][pageTemplateId]
194
- ? []
195
- : pagesGroupedByTemplateId[`${cardType}_${market}`][pageTemplateId];
196
- } else {
197
- pagesList = pagesMappedById.map((page) => page);
198
- }
199
-
200
- // Check if there are pages before starting filtering
201
- if (pagesList.length > 0) {
202
- if (!cardItems[b64]) {
203
- const pagesFilteredByAuthor = filterPages(
204
- pagesList,
205
- selectedAuthors,
206
- "author_id"
207
- );
208
-
209
- // Filter by reviewer
210
- const pagesFilteredByReviewer = filterPages(
211
- pagesFilteredByAuthor,
212
- selectedReviewer,
213
- "reviewer_id"
214
- );
215
-
216
- const pagesFilteredByAuthorAndCategory = filterPages(
217
- pagesFilteredByReviewer,
218
- selectedCategories,
219
- "categoryIds",
220
- pageId
221
- );
222
-
223
- // Removing any duplicate pages in the final array (because pages may have more than one category)
224
- const filteredPages = removeDuplicates(
225
- pagesFilteredByAuthorAndCategory,
226
- "id"
227
- );
228
-
229
- let finalizedFilteredPages = [];
230
- switch (cardType) {
231
- case "game":
232
- finalizedFilteredPages = filterGames(
233
- filteredPages,
234
- moduleSelectedCategories,
235
- moduleSelectedProviders
236
- );
237
- break;
238
- case "operator":
239
- finalizedFilteredPages = filterOperators(
240
- filteredPages,
241
- moduleSelectedProviders,
242
- moduleSelectedTypes
243
- );
244
- break;
245
- case "event":
246
- finalizedFilteredPages = filterEvents(filteredPages);
247
- break;
248
- default:
249
- finalizedFilteredPages = filteredPages;
250
- }
251
- const uniquePages = removeCurrentPage(
252
- removeDuplicates(finalizedFilteredPages, "id"),
253
- pageId
254
- );
255
- cardItems[b64] = uniquePages;
256
- }
257
- const itemLimit = module.cards_selector_filters_limit || 50;
258
- // Applying sorting
259
- if (sortType === "random") {
260
- module.items = sampleSize(cardItems[b64], itemLimit);
261
- } else if (sortType === "latest") {
262
- if (cardItems[b64].length > 0) {
263
- cardItems[b64].sort((a, b) => (a.created_at > b.created_at ? -1 : 1));
264
- module.items = cardItems[b64].slice(0, itemLimit);
265
- }
266
- } else if (sortType === "alphabetical") {
267
- if (cardItems[b64].length > 0) {
268
- cardItems[b64].sort((a, b) => {
269
- if (a.title < b.title) {
270
- return -1;
271
- }
272
- if (a.title > b.title) {
273
- return 1;
274
- }
275
- return 0;
276
- });
277
- module.items = module.cards_selector_filters_limit
278
- ? cardItems[b64].slice(0, module.cards_selector_filters_limit)
279
- : cardItems[b64];
280
- }
281
- }
282
- }
302
+ sortType,
303
+ market,
304
+ content,
305
+ pageId,
306
+ selectedAuthors: page_authors,
307
+ selectedReviewer: page_reviewer,
308
+ selectedCategories: page_categories,
309
+ selectedProviders: moduleSelectedProviders,
310
+ selectedTypes: moduleSelectedTypes,
311
+ limit,
312
+ });
283
313
  }
284
314
 
285
315
  if (styleName !== "comparison_table") {
@@ -491,8 +521,9 @@ export function processContentModule(
491
521
  content,
492
522
  previewPageID
493
523
  ) {
494
-
495
- module.value = previewPageID ? module.value : (content && content[module.value]) || "";
524
+ module.value = previewPageID
525
+ ? module.value
526
+ : (content && content[module.value]) || "";
496
527
 
497
528
  module.value = generatePlaceholderString(
498
529
  module.value,
@@ -614,6 +645,7 @@ export function processModule(
614
645
  data,
615
646
  toplists,
616
647
  content,
648
+ prefilledMarketModules,
617
649
  previewPageID
618
650
  ) {
619
651
  module.module_title =
@@ -635,9 +667,22 @@ export function processModule(
635
667
  }
636
668
 
637
669
  if (module.name === "cards_v2") {
638
- processCardsV2(module, pages, pagesMappedById, pageId, content);
670
+ processCardsV2(
671
+ module,
672
+ pages,
673
+ pagesMappedById,
674
+ pageId,
675
+ content,
676
+ prefilledMarketModules
677
+ );
639
678
  } else if (module.name === "content") {
640
- processContentModule(module, translations, relationData, content, previewPageID);
679
+ processContentModule(
680
+ module,
681
+ translations,
682
+ relationData,
683
+ content,
684
+ previewPageID
685
+ );
641
686
  } else if (module.name === "bonus") {
642
687
  processBonus(module, relations, data);
643
688
  } else if (module.name === "top_list") {
@@ -10,7 +10,7 @@ import {
10
10
  processTopListModule,
11
11
  shouldSavePrefilled,
12
12
  processContentModule,
13
- processAnchor
13
+ processAnchor,
14
14
  } from "./modules.mjs";
15
15
  import { objectsHolder } from "~tests/factories/modules/modules.factory";
16
16
  import getPageDataList from "~tests/factories/pages/list.factory";
@@ -326,4 +326,60 @@ describe("Modules Helper", () => {
326
326
  expect(processedAnchor.items[0].label).toBe(text0.replace('[YEAR]', year));
327
327
  expect(processedAnchor.items[1].label).toBe(text1.replace('[operator_name]', page?.relation.name));
328
328
  });
329
- });
329
+
330
+
331
+ test("Cards V2 Prefilled module with use_filters - game type", () => {
332
+ process.env.GATSBY_SITE_NAME = "default";
333
+
334
+ const pagesNum = 5;
335
+ const pageList = getPageDataList(pagesNum).map((page) => ({
336
+ ...page,
337
+ relation_type: "game",
338
+ template_id: "game_template",
339
+ relation: {
340
+ game_categories: [{ id: 1 }],
341
+ game_provider: { id: 2 },
342
+ },
343
+ author_id: 1,
344
+ reviewer_id: 1,
345
+ categoryIds: [1],
346
+ }));
347
+
348
+ const pagesCloned = groupBy(pageList, "relation_type");
349
+ const pagesMappedById = groupBy(pageList, "id", true);
350
+
351
+ const prefilledModule = {
352
+ module_value_id: 111,
353
+ cards_selector: "use_filters",
354
+ cards_page_type: "game",
355
+ cards_page_type_id: "game_template",
356
+ cards_selector_filters: {
357
+ page_authors: [1],
358
+ page_categories: [1],
359
+ providers: [2],
360
+ categories: [1],
361
+ },
362
+ cards_selector_filters_limit: 3,
363
+ cards_selector_filters_sort_by: "latest",
364
+ style: "default",
365
+ items: [],
366
+ };
367
+
368
+ const prefilledMarketModules = {
369
+ 111: prefilledModule,
370
+ };
371
+
372
+ processCardsV2(
373
+ prefilledModule,
374
+ pagesCloned,
375
+ pagesMappedById,
376
+ 1,
377
+ {},
378
+ prefilledMarketModules
379
+ );
380
+
381
+ expect(prefilledModule.items).toHaveLength(3);
382
+ });
383
+
384
+
385
+ })