@decocms/apps 1.6.1 → 1.6.2
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/package.json
CHANGED
|
@@ -152,6 +152,7 @@ function facetToToggle(
|
|
|
152
152
|
selectedFacets: SelectedFacet[],
|
|
153
153
|
key: string,
|
|
154
154
|
paramsToPersist?: URLSearchParams,
|
|
155
|
+
basePath = "",
|
|
155
156
|
) {
|
|
156
157
|
return (item: ISFacetValueBoolean | ISFacetValueRange) => {
|
|
157
158
|
const { quantity, selected } = item;
|
|
@@ -170,19 +171,23 @@ function facetToToggle(
|
|
|
170
171
|
value,
|
|
171
172
|
quantity,
|
|
172
173
|
selected,
|
|
173
|
-
url:
|
|
174
|
+
url: `${basePath}?${filtersToSearchParams(filters, paramsToPersist)}`,
|
|
174
175
|
label,
|
|
175
176
|
};
|
|
176
177
|
};
|
|
177
178
|
}
|
|
178
179
|
|
|
179
|
-
function toFilter(
|
|
180
|
+
function toFilter(
|
|
181
|
+
selectedFacets: SelectedFacet[],
|
|
182
|
+
paramsToPersist?: URLSearchParams,
|
|
183
|
+
basePath = "",
|
|
184
|
+
) {
|
|
180
185
|
return (facet: ISFacet) => ({
|
|
181
186
|
"@type": "FilterToggle" as const,
|
|
182
187
|
key: facet.key,
|
|
183
188
|
label: facet.name,
|
|
184
189
|
quantity: facet.quantity,
|
|
185
|
-
values: facet.values.map(facetToToggle(selectedFacets, facet.key, paramsToPersist)),
|
|
190
|
+
values: facet.values.map(facetToToggle(selectedFacets, facet.key, paramsToPersist, basePath)),
|
|
186
191
|
});
|
|
187
192
|
}
|
|
188
193
|
|
|
@@ -409,7 +414,8 @@ export default async function vtexProductListingPage(props: PLPProps): Promise<a
|
|
|
409
414
|
|
|
410
415
|
// 4. Transform facets to filters (matching original toFilter)
|
|
411
416
|
const visibleFacets = facetsResult.facets.filter((f) => !f.hidden);
|
|
412
|
-
const
|
|
417
|
+
const basePath = __pagePath && __pagePath !== "/" ? __pagePath : "";
|
|
418
|
+
const filters = visibleFacets.map(toFilter(facets, paramsToPersist, basePath));
|
|
413
419
|
|
|
414
420
|
// 5. Build pagination (matching original logic)
|
|
415
421
|
const currentPageoffset = 1;
|
|
@@ -444,8 +450,8 @@ export default async function vtexProductListingPage(props: PLPProps): Promise<a
|
|
|
444
450
|
filters,
|
|
445
451
|
products: schemaProducts,
|
|
446
452
|
pageInfo: {
|
|
447
|
-
nextPage: hasNextPage ?
|
|
448
|
-
previousPage: hasPreviousPage ?
|
|
453
|
+
nextPage: hasNextPage ? `${basePath}?${nextPageParams}` : undefined,
|
|
454
|
+
previousPage: hasPreviousPage ? `${basePath}?${prevPageParams}` : undefined,
|
|
449
455
|
currentPage: page + currentPageoffset,
|
|
450
456
|
records: recordsFiltered,
|
|
451
457
|
recordPerPage: pagination.perPage,
|
package/vtex/loaders/legacy.ts
CHANGED
|
@@ -531,8 +531,8 @@ export async function legacyProductListingPage(
|
|
|
531
531
|
filters,
|
|
532
532
|
products,
|
|
533
533
|
pageInfo: {
|
|
534
|
-
nextPage: hasNextPage ?
|
|
535
|
-
previousPage: hasPreviousPage ?
|
|
534
|
+
nextPage: hasNextPage ? `${url.pathname}?${nextPage.toString()}` : undefined,
|
|
535
|
+
previousPage: hasPreviousPage ? `${url.pathname}?${previousPage.toString()}` : undefined,
|
|
536
536
|
currentPage,
|
|
537
537
|
records: totalRecords,
|
|
538
538
|
recordPerPage: count,
|