@wix/headless-stores 0.0.41 → 0.0.43
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/cjs/dist/react/ProductList.d.ts +31 -3
- package/cjs/dist/react/ProductList.js +33 -5
- package/cjs/dist/react/ProductListFilters.d.ts +100 -111
- package/cjs/dist/react/ProductListFilters.js +105 -115
- package/cjs/dist/react/ProductListPagination.d.ts +89 -96
- package/cjs/dist/react/ProductListPagination.js +96 -104
- package/cjs/dist/react/ProductListSort.d.ts +26 -57
- package/cjs/dist/react/ProductListSort.js +26 -58
- package/cjs/dist/services/index.d.ts +1 -3
- package/cjs/dist/services/index.js +1 -3
- package/cjs/dist/services/products-list-search-service.d.ts +220 -0
- package/cjs/dist/services/products-list-search-service.js +813 -0
- package/cjs/dist/services/products-list-service.d.ts +28 -11
- package/cjs/dist/services/products-list-service.js +26 -6
- package/dist/react/ProductList.d.ts +31 -3
- package/dist/react/ProductList.js +33 -5
- package/dist/react/ProductListFilters.d.ts +100 -111
- package/dist/react/ProductListFilters.js +105 -115
- package/dist/react/ProductListPagination.d.ts +89 -96
- package/dist/react/ProductListPagination.js +96 -104
- package/dist/react/ProductListSort.d.ts +26 -57
- package/dist/react/ProductListSort.js +26 -58
- package/dist/services/index.d.ts +1 -3
- package/dist/services/index.js +1 -3
- package/dist/services/products-list-search-service.d.ts +220 -0
- package/dist/services/products-list-search-service.js +813 -0
- package/dist/services/products-list-service.d.ts +28 -11
- package/dist/services/products-list-service.js +26 -6
- package/package.json +2 -2
- package/cjs/dist/services/products-list-filters-service.d.ts +0 -309
- package/cjs/dist/services/products-list-filters-service.js +0 -504
- package/cjs/dist/services/products-list-pagination-service.d.ts +0 -186
- package/cjs/dist/services/products-list-pagination-service.js +0 -179
- package/cjs/dist/services/products-list-sort-service.d.ts +0 -117
- package/cjs/dist/services/products-list-sort-service.js +0 -144
- package/dist/services/products-list-filters-service.d.ts +0 -309
- package/dist/services/products-list-filters-service.js +0 -504
- package/dist/services/products-list-pagination-service.d.ts +0 -186
- package/dist/services/products-list-pagination-service.js +0 -179
- package/dist/services/products-list-sort-service.d.ts +0 -117
- package/dist/services/products-list-sort-service.js +0 -144
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { defineService } from "@wix/services-definitions";
|
|
2
|
-
import { implementService } from "@wix/services-definitions";
|
|
3
|
-
import { SignalsServiceDefinition, } from "@wix/services-definitions/core-services/signals";
|
|
4
|
-
import { ProductsListServiceDefinition } from "./products-list-service.js";
|
|
5
|
-
/**
|
|
6
|
-
* Service definition for the Products List Pagination service.
|
|
7
|
-
* This defines the reactive API contract for managing product list pagination state and navigation.
|
|
8
|
-
*
|
|
9
|
-
* @constant
|
|
10
|
-
*/
|
|
11
|
-
export const ProductsListPaginationServiceDefinition = defineService("products-list-pagination");
|
|
12
|
-
/**
|
|
13
|
-
* Implementation of the Products List Pagination service that manages reactive pagination state.
|
|
14
|
-
* This service provides signals for pagination state and automatically updates the products list
|
|
15
|
-
* search options when pagination settings change. It supports both cursor-based pagination
|
|
16
|
-
* and load-more functionality.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```tsx
|
|
20
|
-
* import { ProductsListPaginationService, ProductsListPaginationServiceDefinition } from '@wix/stores/services';
|
|
21
|
-
* import { useService } from '@wix/services-manager-react';
|
|
22
|
-
*
|
|
23
|
-
* function PaginationComponent() {
|
|
24
|
-
* return (
|
|
25
|
-
* <ServiceProvider services={createServicesMap([
|
|
26
|
-
* [ProductsListPaginationServiceDefinition, ProductsListPaginationService.withConfig({})]
|
|
27
|
-
* ])}>
|
|
28
|
-
* <PaginationControls />
|
|
29
|
-
* </ServiceProvider>
|
|
30
|
-
* );
|
|
31
|
-
* }
|
|
32
|
-
*
|
|
33
|
-
* function PaginationControls() {
|
|
34
|
-
* const paginationService = useService(ProductsListPaginationServiceDefinition);
|
|
35
|
-
* const currentLimit = paginationService.currentLimit.get();
|
|
36
|
-
* const hasNextPage = paginationService.hasNextPage.get();
|
|
37
|
-
* const hasPrevPage = paginationService.hasPrevPage.get();
|
|
38
|
-
*
|
|
39
|
-
* return (
|
|
40
|
-
* <div>
|
|
41
|
-
* <div>
|
|
42
|
-
* Items per page:
|
|
43
|
-
* <select
|
|
44
|
-
* value={currentLimit}
|
|
45
|
-
* onChange={(e) => paginationService.setLimit(parseInt(e.target.value))}
|
|
46
|
-
* >
|
|
47
|
-
* <option value={12}>12</option>
|
|
48
|
-
* <option value={24}>24</option>
|
|
49
|
-
* <option value={48}>48</option>
|
|
50
|
-
* </select>
|
|
51
|
-
* </div>
|
|
52
|
-
*
|
|
53
|
-
* <div>
|
|
54
|
-
* <button
|
|
55
|
-
* onClick={() => paginationService.navigateToFirstPage()}
|
|
56
|
-
* disabled={!hasPrevPage}
|
|
57
|
-
* >
|
|
58
|
-
* First
|
|
59
|
-
* </button>
|
|
60
|
-
* <button
|
|
61
|
-
* onClick={() => paginationService.prevPage()}
|
|
62
|
-
* disabled={!hasPrevPage}
|
|
63
|
-
* >
|
|
64
|
-
* Previous
|
|
65
|
-
* </button>
|
|
66
|
-
* <button
|
|
67
|
-
* onClick={() => paginationService.nextPage()}
|
|
68
|
-
* disabled={!hasNextPage}
|
|
69
|
-
* >
|
|
70
|
-
* Next
|
|
71
|
-
* </button>
|
|
72
|
-
* </div>
|
|
73
|
-
*
|
|
74
|
-
* <button onClick={() => paginationService.loadMore(12)}>
|
|
75
|
-
* Load More
|
|
76
|
-
* </button>
|
|
77
|
-
* </div>
|
|
78
|
-
* );
|
|
79
|
-
* }
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
|
-
export const ProductsListPaginationService = implementService.withConfig()(ProductsListPaginationServiceDefinition, ({ getService }) => {
|
|
83
|
-
let firstRun = true;
|
|
84
|
-
const signalsService = getService(SignalsServiceDefinition);
|
|
85
|
-
const productsListService = getService(ProductsListServiceDefinition);
|
|
86
|
-
const currentLimitSignal = signalsService.signal(getCurrentLimit(productsListService.searchOptions.get()));
|
|
87
|
-
const currentCursorSignal = signalsService.signal(getCurrentCursor(productsListService.searchOptions.get()));
|
|
88
|
-
// Computed signals derived from paging metadata
|
|
89
|
-
const hasNextPageSignal = signalsService.computed(() => {
|
|
90
|
-
const pagingMetadata = productsListService.pagingMetadata.get();
|
|
91
|
-
return pagingMetadata?.hasNext || false;
|
|
92
|
-
});
|
|
93
|
-
const hasPrevPageSignal = signalsService.computed(() => {
|
|
94
|
-
const pagingMetadata = productsListService.pagingMetadata.get();
|
|
95
|
-
return typeof pagingMetadata.cursors?.prev !== "undefined";
|
|
96
|
-
});
|
|
97
|
-
if (typeof window !== "undefined") {
|
|
98
|
-
// Watch for changes in pagination settings and update search options
|
|
99
|
-
signalsService.effect(() => {
|
|
100
|
-
// CRITICAL: Read the signals FIRST to establish dependencies, even on first run
|
|
101
|
-
const limit = currentLimitSignal.get();
|
|
102
|
-
const cursor = currentCursorSignal.get();
|
|
103
|
-
if (firstRun) {
|
|
104
|
-
firstRun = false;
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
// Build new search options with updated pagination
|
|
108
|
-
const newSearchOptions = {
|
|
109
|
-
...productsListService.searchOptions.peek(),
|
|
110
|
-
};
|
|
111
|
-
// Update cursor paging
|
|
112
|
-
if (limit > 0) {
|
|
113
|
-
newSearchOptions.cursorPaging = {
|
|
114
|
-
limit,
|
|
115
|
-
...(cursor && { cursor }),
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
delete newSearchOptions.cursorPaging;
|
|
120
|
-
}
|
|
121
|
-
// Use callback to update search options
|
|
122
|
-
productsListService.setSearchOptions(newSearchOptions);
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
return {
|
|
126
|
-
currentLimit: currentLimitSignal,
|
|
127
|
-
currentCursor: currentCursorSignal,
|
|
128
|
-
hasNextPage: hasNextPageSignal,
|
|
129
|
-
hasPrevPage: hasPrevPageSignal,
|
|
130
|
-
setLimit: (limit) => {
|
|
131
|
-
currentLimitSignal.set(limit);
|
|
132
|
-
// Reset pagination when changing page size
|
|
133
|
-
currentCursorSignal.set(null);
|
|
134
|
-
},
|
|
135
|
-
loadMore: (count) => {
|
|
136
|
-
const limit = currentLimitSignal.get();
|
|
137
|
-
currentLimitSignal.set(limit + count);
|
|
138
|
-
},
|
|
139
|
-
nextPage: () => {
|
|
140
|
-
const pagingMetadata = productsListService.pagingMetadata.get();
|
|
141
|
-
const nextCursor = pagingMetadata?.cursors?.next;
|
|
142
|
-
if (nextCursor) {
|
|
143
|
-
currentCursorSignal.set(nextCursor);
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
prevPage: () => {
|
|
147
|
-
const pagingMetadata = productsListService.pagingMetadata.get();
|
|
148
|
-
const previousCursor = pagingMetadata?.cursors?.prev;
|
|
149
|
-
if (previousCursor) {
|
|
150
|
-
currentCursorSignal.set(previousCursor);
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
navigateToFirstPage: () => {
|
|
154
|
-
currentCursorSignal.set(null);
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
});
|
|
158
|
-
/**
|
|
159
|
-
* Helper function to extract the current limit from search options.
|
|
160
|
-
* Returns the pagination limit or a default value of 100 if not specified.
|
|
161
|
-
*
|
|
162
|
-
* @private
|
|
163
|
-
* @param {Parameters<typeof productsV3.searchProducts>[0]} searchOptions - The search options object
|
|
164
|
-
* @returns {number} The current limit value
|
|
165
|
-
*/
|
|
166
|
-
function getCurrentLimit(searchOptions) {
|
|
167
|
-
return searchOptions.cursorPaging?.limit || 100;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Helper function to extract the current cursor from search options.
|
|
171
|
-
* Returns the cursor string or null if not specified.
|
|
172
|
-
*
|
|
173
|
-
* @private
|
|
174
|
-
* @param {Parameters<typeof productsV3.searchProducts>[0]} searchOptions - The search options object
|
|
175
|
-
* @returns {string | null} The current cursor value or null
|
|
176
|
-
*/
|
|
177
|
-
function getCurrentCursor(searchOptions) {
|
|
178
|
-
return searchOptions.cursorPaging?.cursor || null;
|
|
179
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import type { Signal } from "@wix/services-definitions/core-services/signals";
|
|
2
|
-
/**
|
|
3
|
-
* Service definition for the Products List Sort service.
|
|
4
|
-
* This defines the reactive API contract for managing product list sorting options.
|
|
5
|
-
*
|
|
6
|
-
* @constant
|
|
7
|
-
*/
|
|
8
|
-
export declare const ProductsListSortServiceDefinition: string & {
|
|
9
|
-
__api: {
|
|
10
|
-
/** Reactive signal containing the currently selected sort option */
|
|
11
|
-
selectedSortOption: Signal<string>;
|
|
12
|
-
/** Function to update the selected sort option */
|
|
13
|
-
setSelectedSortOption: (sort: string) => void;
|
|
14
|
-
/** Array of available sort types */
|
|
15
|
-
sortOptions: SortType[];
|
|
16
|
-
};
|
|
17
|
-
__config: {};
|
|
18
|
-
isServiceDefinition?: boolean;
|
|
19
|
-
} & {
|
|
20
|
-
/** Reactive signal containing the currently selected sort option */
|
|
21
|
-
selectedSortOption: Signal<string>;
|
|
22
|
-
/** Function to update the selected sort option */
|
|
23
|
-
setSelectedSortOption: (sort: string) => void;
|
|
24
|
-
/** Array of available sort types */
|
|
25
|
-
sortOptions: SortType[];
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Configuration interface for the Products List Sort service.
|
|
29
|
-
* Currently empty as this service doesn't require initial configuration.
|
|
30
|
-
*
|
|
31
|
-
* @interface ProductsListSortServiceConfig
|
|
32
|
-
*/
|
|
33
|
-
export type ProductsListSortServiceConfig = {};
|
|
34
|
-
/**
|
|
35
|
-
* Enumeration of available product sort types.
|
|
36
|
-
* These values correspond to how products can be sorted in the product list.
|
|
37
|
-
*
|
|
38
|
-
* @enum {string}
|
|
39
|
-
*/
|
|
40
|
-
export declare enum SortType {
|
|
41
|
-
/** Sort by newest products first */
|
|
42
|
-
NEWEST = "newest",
|
|
43
|
-
/** Sort by product name in ascending order (A-Z) */
|
|
44
|
-
NAME_ASC = "name_asc",
|
|
45
|
-
/** Sort by product name in descending order (Z-A) */
|
|
46
|
-
NAME_DESC = "name_desc",
|
|
47
|
-
/** Sort by price in ascending order (lowest first) */
|
|
48
|
-
PRICE_ASC = "price_asc",
|
|
49
|
-
/** Sort by price in descending order (highest first) */
|
|
50
|
-
PRICE_DESC = "price_desc",
|
|
51
|
-
/** Sort by recommended products (algorithm-based) */
|
|
52
|
-
RECOMMENDED = "recommended"
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Implementation of the Products List Sort service that manages reactive sorting state.
|
|
56
|
-
* This service provides signals for the current sort option and automatically updates
|
|
57
|
-
* the products list search options when the sort selection changes.
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```tsx
|
|
61
|
-
* import { ProductsListSortService, ProductsListSortServiceDefinition, SortType } from '@wix/stores/services';
|
|
62
|
-
* import { useService } from '@wix/services-manager-react';
|
|
63
|
-
*
|
|
64
|
-
* function SortComponent() {
|
|
65
|
-
* return (
|
|
66
|
-
* <ServiceProvider services={createServicesMap([
|
|
67
|
-
* [ProductsListSortServiceDefinition, ProductsListSortService.withConfig({})]
|
|
68
|
-
* ])}>
|
|
69
|
-
* <SortSelector />
|
|
70
|
-
* </ServiceProvider>
|
|
71
|
-
* );
|
|
72
|
-
* }
|
|
73
|
-
*
|
|
74
|
-
* function SortSelector() {
|
|
75
|
-
* const sortService = useService(ProductsListSortServiceDefinition);
|
|
76
|
-
* const selectedSort = sortService.selectedSortOption.get();
|
|
77
|
-
* const sortOptions = sortService.sortOptions;
|
|
78
|
-
*
|
|
79
|
-
* return (
|
|
80
|
-
* <select
|
|
81
|
-
* value={selectedSort}
|
|
82
|
-
* onChange={(e) => sortService.setSelectedSortOption(e.target.value)}
|
|
83
|
-
* >
|
|
84
|
-
* {sortOptions.map(option => (
|
|
85
|
-
* <option key={option} value={option}>
|
|
86
|
-
* {option === SortType.NAME_ASC ? 'Name A-Z' :
|
|
87
|
-
* option === SortType.NAME_DESC ? 'Name Z-A' :
|
|
88
|
-
* option === SortType.PRICE_ASC ? 'Price Low to High' :
|
|
89
|
-
* option === SortType.PRICE_DESC ? 'Price High to Low' :
|
|
90
|
-
* option === SortType.NEWEST ? 'Newest First' :
|
|
91
|
-
* 'Recommended'}
|
|
92
|
-
* </option>
|
|
93
|
-
* ))}
|
|
94
|
-
* </select>
|
|
95
|
-
* );
|
|
96
|
-
* }
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
99
|
-
export declare const ProductsListSortService: import("@wix/services-definitions").ServiceFactory<string & {
|
|
100
|
-
__api: {
|
|
101
|
-
/** Reactive signal containing the currently selected sort option */
|
|
102
|
-
selectedSortOption: Signal<string>;
|
|
103
|
-
/** Function to update the selected sort option */
|
|
104
|
-
setSelectedSortOption: (sort: string) => void;
|
|
105
|
-
/** Array of available sort types */
|
|
106
|
-
sortOptions: SortType[];
|
|
107
|
-
};
|
|
108
|
-
__config: {};
|
|
109
|
-
isServiceDefinition?: boolean;
|
|
110
|
-
} & {
|
|
111
|
-
/** Reactive signal containing the currently selected sort option */
|
|
112
|
-
selectedSortOption: Signal<string>;
|
|
113
|
-
/** Function to update the selected sort option */
|
|
114
|
-
setSelectedSortOption: (sort: string) => void;
|
|
115
|
-
/** Array of available sort types */
|
|
116
|
-
sortOptions: SortType[];
|
|
117
|
-
}, ProductsListSortServiceConfig>;
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { defineService, implementService } from "@wix/services-definitions";
|
|
2
|
-
import { SignalsServiceDefinition } from "@wix/services-definitions/core-services/signals";
|
|
3
|
-
import { ProductsListServiceDefinition } from "./products-list-service.js";
|
|
4
|
-
import { productsV3 } from "@wix/stores";
|
|
5
|
-
/**
|
|
6
|
-
* Service definition for the Products List Sort service.
|
|
7
|
-
* This defines the reactive API contract for managing product list sorting options.
|
|
8
|
-
*
|
|
9
|
-
* @constant
|
|
10
|
-
*/
|
|
11
|
-
export const ProductsListSortServiceDefinition = defineService("products-list-sort");
|
|
12
|
-
/**
|
|
13
|
-
* Enumeration of available product sort types.
|
|
14
|
-
* These values correspond to how products can be sorted in the product list.
|
|
15
|
-
*
|
|
16
|
-
* @enum {string}
|
|
17
|
-
*/
|
|
18
|
-
export var SortType;
|
|
19
|
-
(function (SortType) {
|
|
20
|
-
/** Sort by newest products first */
|
|
21
|
-
SortType["NEWEST"] = "newest";
|
|
22
|
-
/** Sort by product name in ascending order (A-Z) */
|
|
23
|
-
SortType["NAME_ASC"] = "name_asc";
|
|
24
|
-
/** Sort by product name in descending order (Z-A) */
|
|
25
|
-
SortType["NAME_DESC"] = "name_desc";
|
|
26
|
-
/** Sort by price in ascending order (lowest first) */
|
|
27
|
-
SortType["PRICE_ASC"] = "price_asc";
|
|
28
|
-
/** Sort by price in descending order (highest first) */
|
|
29
|
-
SortType["PRICE_DESC"] = "price_desc";
|
|
30
|
-
/** Sort by recommended products (algorithm-based) */
|
|
31
|
-
SortType["RECOMMENDED"] = "recommended";
|
|
32
|
-
})(SortType || (SortType = {}));
|
|
33
|
-
/**
|
|
34
|
-
* Implementation of the Products List Sort service that manages reactive sorting state.
|
|
35
|
-
* This service provides signals for the current sort option and automatically updates
|
|
36
|
-
* the products list search options when the sort selection changes.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```tsx
|
|
40
|
-
* import { ProductsListSortService, ProductsListSortServiceDefinition, SortType } from '@wix/stores/services';
|
|
41
|
-
* import { useService } from '@wix/services-manager-react';
|
|
42
|
-
*
|
|
43
|
-
* function SortComponent() {
|
|
44
|
-
* return (
|
|
45
|
-
* <ServiceProvider services={createServicesMap([
|
|
46
|
-
* [ProductsListSortServiceDefinition, ProductsListSortService.withConfig({})]
|
|
47
|
-
* ])}>
|
|
48
|
-
* <SortSelector />
|
|
49
|
-
* </ServiceProvider>
|
|
50
|
-
* );
|
|
51
|
-
* }
|
|
52
|
-
*
|
|
53
|
-
* function SortSelector() {
|
|
54
|
-
* const sortService = useService(ProductsListSortServiceDefinition);
|
|
55
|
-
* const selectedSort = sortService.selectedSortOption.get();
|
|
56
|
-
* const sortOptions = sortService.sortOptions;
|
|
57
|
-
*
|
|
58
|
-
* return (
|
|
59
|
-
* <select
|
|
60
|
-
* value={selectedSort}
|
|
61
|
-
* onChange={(e) => sortService.setSelectedSortOption(e.target.value)}
|
|
62
|
-
* >
|
|
63
|
-
* {sortOptions.map(option => (
|
|
64
|
-
* <option key={option} value={option}>
|
|
65
|
-
* {option === SortType.NAME_ASC ? 'Name A-Z' :
|
|
66
|
-
* option === SortType.NAME_DESC ? 'Name Z-A' :
|
|
67
|
-
* option === SortType.PRICE_ASC ? 'Price Low to High' :
|
|
68
|
-
* option === SortType.PRICE_DESC ? 'Price High to Low' :
|
|
69
|
-
* option === SortType.NEWEST ? 'Newest First' :
|
|
70
|
-
* 'Recommended'}
|
|
71
|
-
* </option>
|
|
72
|
-
* ))}
|
|
73
|
-
* </select>
|
|
74
|
-
* );
|
|
75
|
-
* }
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
export const ProductsListSortService = implementService.withConfig()(ProductsListSortServiceDefinition, ({ getService }) => {
|
|
79
|
-
let firstRun = true;
|
|
80
|
-
const signalsService = getService(SignalsServiceDefinition);
|
|
81
|
-
const productsListService = getService(ProductsListServiceDefinition);
|
|
82
|
-
const selectedSortOptionSignal = signalsService.signal("name");
|
|
83
|
-
if (typeof window !== "undefined") {
|
|
84
|
-
signalsService.effect(() => {
|
|
85
|
-
const sort = selectedSortOptionSignal.get();
|
|
86
|
-
if (firstRun) {
|
|
87
|
-
firstRun = false;
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
const newSearchOptions = {
|
|
91
|
-
...productsListService.searchOptions.peek(),
|
|
92
|
-
};
|
|
93
|
-
if (!newSearchOptions.sort) {
|
|
94
|
-
newSearchOptions.sort = [];
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
// Copy existing filter to avoid mutation
|
|
98
|
-
newSearchOptions.sort = [...newSearchOptions.sort];
|
|
99
|
-
}
|
|
100
|
-
switch (sort) {
|
|
101
|
-
case SortType.NAME_ASC:
|
|
102
|
-
newSearchOptions.sort = [
|
|
103
|
-
{ fieldName: "name", order: productsV3.SortDirection.ASC },
|
|
104
|
-
];
|
|
105
|
-
break;
|
|
106
|
-
case SortType.NAME_DESC:
|
|
107
|
-
newSearchOptions.sort = [
|
|
108
|
-
{ fieldName: "name", order: productsV3.SortDirection.DESC },
|
|
109
|
-
];
|
|
110
|
-
break;
|
|
111
|
-
case SortType.PRICE_ASC:
|
|
112
|
-
newSearchOptions.sort = [
|
|
113
|
-
{
|
|
114
|
-
fieldName: "actualPriceRange.minValue.amount",
|
|
115
|
-
order: productsV3.SortDirection.ASC,
|
|
116
|
-
},
|
|
117
|
-
];
|
|
118
|
-
break;
|
|
119
|
-
case SortType.PRICE_DESC:
|
|
120
|
-
newSearchOptions.sort = [
|
|
121
|
-
{
|
|
122
|
-
fieldName: "actualPriceRange.minValue.amount",
|
|
123
|
-
order: productsV3.SortDirection.DESC,
|
|
124
|
-
},
|
|
125
|
-
];
|
|
126
|
-
break;
|
|
127
|
-
case SortType.RECOMMENDED:
|
|
128
|
-
newSearchOptions.sort = [
|
|
129
|
-
{
|
|
130
|
-
fieldName: "name",
|
|
131
|
-
order: productsV3.SortDirection.DESC,
|
|
132
|
-
},
|
|
133
|
-
];
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
productsListService.setSearchOptions(newSearchOptions);
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
selectedSortOption: selectedSortOptionSignal,
|
|
141
|
-
sortOptions: Object.values(SortType),
|
|
142
|
-
setSelectedSortOption: (sort) => selectedSortOptionSignal.set(sort),
|
|
143
|
-
};
|
|
144
|
-
});
|