@akinon/projectzero 1.48.0-rc.1 → 1.48.0-rc.3
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 +13 -0
- package/app-template/CHANGELOG.md +144 -0
- package/app-template/package.json +16 -16
- package/app-template/src/components/pagination.tsx +13 -18
- package/app-template/src/views/category/category-active-filters.tsx +16 -6
- package/app-template/src/views/category/filters/filter-item.tsx +57 -25
- package/app-template/src/views/category/filters/index.tsx +16 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @akinon/projectzero
|
|
2
2
|
|
|
3
|
+
## 1.48.0-rc.3
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 90282b53: ZERO-2729: Audit packages for yarn and npm and also update app-template
|
|
8
|
+
- 03c4c3eb: ZERO-2731: Update Project Zero CLI command
|
|
9
|
+
- 64699d3: ZERO-2761: Fix invalid import for plugin module
|
|
10
|
+
- 9b6bf91e: ZERO-2660: Change campaings to campaigns
|
|
11
|
+
- 00ffde2f: ZERO-2637: enhance create command with improved messaging
|
|
12
|
+
- d2f0f15c: ZERO-2723: Update sentry version and dependencies
|
|
13
|
+
|
|
14
|
+
## 1.48.0-rc.2
|
|
15
|
+
|
|
3
16
|
## 1.48.0-rc.1
|
|
4
17
|
|
|
5
18
|
## 1.48.0-rc.0
|
|
@@ -1,5 +1,149 @@
|
|
|
1
1
|
# projectzeronext
|
|
2
2
|
|
|
3
|
+
## 1.48.0-rc.3
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 90282b53: ZERO-2729: Audit packages for yarn and npm and also update app-template
|
|
8
|
+
- 572d2e84: ZERO-2667: Add iframe support for redirection payment methods
|
|
9
|
+
- c53ea3e6: ZERO-2609: Reset additional form fields when selectedFormType is not company
|
|
10
|
+
- 97b8bdc9: ZERO-2724: Remove onClick event in shipping options component
|
|
11
|
+
- 714e0b46: ZERO-2759: update pz-click-collect peer dependencies
|
|
12
|
+
- 7521265: ZERO-2787: Fix hover classname for favorite item
|
|
13
|
+
- 8217463: ZERO-2887: Add LoaderSpinner to Filters component
|
|
14
|
+
- 27a5296d: ZERO-2631:Fix Checkbox Click
|
|
15
|
+
- 5a4c607: ZERO-2764: Add case-warning rule to eslint-plugin-projectzero
|
|
16
|
+
- bc2b411: ZERO-2825: Add attribute-based shipping options to checkout page
|
|
17
|
+
- e665a0a: ZERO-2625: Add click outside functionality to close mobile menu
|
|
18
|
+
- 52c1373: ZERO-2619: Added fix flag for the staged linter
|
|
19
|
+
- 552ee8a: ZERO-2777: fix link component usage
|
|
20
|
+
- 03c4c3eb: ZERO-2731: Update Project Zero CLI command
|
|
21
|
+
- 2e6104d: ZERO-2888:Edit the numbering in the pagination and the visibility of the prev and next buttons
|
|
22
|
+
- 64699d3: ZERO-2761: Fix invalid import for plugin module
|
|
23
|
+
- 0d3a913e: ZERO-2725: Update decimal scale in Price component
|
|
24
|
+
- 778a9a0b: ZERO-2740: Upgrade next to 14.2.4
|
|
25
|
+
- 9b6bf91e: ZERO-2660: Change campaings to campaigns
|
|
26
|
+
- 06650ca: ZERO-2620: Remove unnecessary pointer-events-none class
|
|
27
|
+
- 74a12699: ZERO-2658:Edit product name clickability on completed order page
|
|
28
|
+
- 4e1c15c: ZERO-2617: Remove TODO comment in ProductInfo component
|
|
29
|
+
- d3474c64: ZERO-2655: Add data source shipping option
|
|
30
|
+
- d2f0f15c: ZERO-2723: Update sentry version and dependencies
|
|
31
|
+
- 75080fd6: ZERO-2630: Add max limit to postcode area
|
|
32
|
+
- 9609eb2: ZERO-2779: Upgrade for tailwind
|
|
33
|
+
- 91265bba: ZERO-2551: Improve pretty url and caching performance
|
|
34
|
+
- 38a634e: ZERO-2893: Refactor category filter handling and URL parameters
|
|
35
|
+
- 959e1fa: ZERO-2778: Upgrade for nextjs
|
|
36
|
+
- 902d828a: ZERO-2621:edit position of loaderSpinner in favorites page
|
|
37
|
+
- 7a4bb764: ZERO-2610:Refactor FilterItem component for better readability and efficiency
|
|
38
|
+
- dfabc06: ZERO-2836: Upgrade version for tailwind
|
|
39
|
+
- dff0d595: ZERO-2659: add formData support to proxy api requests
|
|
40
|
+
- eecb282: ZERO-2607: Update address-related functions to include invalidateTag option
|
|
41
|
+
- 9e25a64: ZERO-2835: Update category page layout with breadcrumb
|
|
42
|
+
- beb499e6: ZERO-2551: Add new tsconfig paths
|
|
43
|
+
- f45aa87: ZERO-2904: Upgrade version for tailwindcss
|
|
44
|
+
- fac2e5b: ZERO-2622: Add isMenuOpen state to Category reducer and update CategoryInfo component
|
|
45
|
+
- 4614eeeb: ZERO-2602: The script that checks the build for standalone projects
|
|
46
|
+
- e9a46acb: ZERO-2738: add CVC input to registered cards in Masterpass
|
|
47
|
+
- f046f8e0: ZERO-2575: update version for react-number-format
|
|
48
|
+
- b9273fd: ZERO-2889: add host headers to requests
|
|
49
|
+
- 86d25315: ZERO-2693: resolve dependency collision warning for eslint-config-next
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- Updated dependencies [90282b53]
|
|
54
|
+
- Updated dependencies [50b9069]
|
|
55
|
+
- Updated dependencies [572d2e84]
|
|
56
|
+
- Updated dependencies [a4c8d6a9]
|
|
57
|
+
- Updated dependencies [fda5b92]
|
|
58
|
+
- Updated dependencies [2d9b2b2]
|
|
59
|
+
- Updated dependencies [c53ea3e6]
|
|
60
|
+
- Updated dependencies [d93a507]
|
|
61
|
+
- Updated dependencies [8d9ac9a]
|
|
62
|
+
- Updated dependencies [18e8197]
|
|
63
|
+
- Updated dependencies [714e0b46]
|
|
64
|
+
- Updated dependencies [70279e7]
|
|
65
|
+
- Updated dependencies [6c25f66]
|
|
66
|
+
- Updated dependencies [bc2b411]
|
|
67
|
+
- Updated dependencies [3bf2dd9]
|
|
68
|
+
- Updated dependencies [e9541a1]
|
|
69
|
+
- Updated dependencies [c53ef7b9]
|
|
70
|
+
- Updated dependencies [9d94f7e]
|
|
71
|
+
- Updated dependencies [2e6104d]
|
|
72
|
+
- Updated dependencies [64699d3]
|
|
73
|
+
- Updated dependencies [0d3a913e]
|
|
74
|
+
- Updated dependencies [1448a96e]
|
|
75
|
+
- Updated dependencies [1ec2e9d]
|
|
76
|
+
- Updated dependencies [d6edb1d]
|
|
77
|
+
- Updated dependencies [d3474c64]
|
|
78
|
+
- Updated dependencies [75080fd6]
|
|
79
|
+
- Updated dependencies [17f8752]
|
|
80
|
+
- Updated dependencies [c45b62c]
|
|
81
|
+
- Updated dependencies [91265bba]
|
|
82
|
+
- Updated dependencies [bbe18b9f]
|
|
83
|
+
- Updated dependencies [d409996]
|
|
84
|
+
- Updated dependencies [4920742]
|
|
85
|
+
- Updated dependencies [12a873e]
|
|
86
|
+
- Updated dependencies [69ca080]
|
|
87
|
+
- Updated dependencies [7e56d6b]
|
|
88
|
+
- Updated dependencies [94b6928]
|
|
89
|
+
- Updated dependencies [98bb8dcd]
|
|
90
|
+
- Updated dependencies [46b7aad]
|
|
91
|
+
- Updated dependencies [dcc8a150]
|
|
92
|
+
- Updated dependencies [8f47cca]
|
|
93
|
+
- Updated dependencies [fad27689]
|
|
94
|
+
- Updated dependencies [dff0d595]
|
|
95
|
+
- Updated dependencies [fdd0b41]
|
|
96
|
+
- Updated dependencies [eecb282]
|
|
97
|
+
- Updated dependencies [f2c325c]
|
|
98
|
+
- Updated dependencies [9e25a64]
|
|
99
|
+
- Updated dependencies [beb499e6]
|
|
100
|
+
- Updated dependencies [146ea39]
|
|
101
|
+
- Updated dependencies [f2c92d5]
|
|
102
|
+
- Updated dependencies [7bd3d99]
|
|
103
|
+
- Updated dependencies [c47be30d]
|
|
104
|
+
- Updated dependencies [e9a46acb]
|
|
105
|
+
- Updated dependencies [f046f8e0]
|
|
106
|
+
- Updated dependencies [b9273fd]
|
|
107
|
+
- Updated dependencies [86d25315]
|
|
108
|
+
- Updated dependencies [c670bd4]
|
|
109
|
+
- Updated dependencies [3f9b8d7]
|
|
110
|
+
- @akinon/next@1.48.0-rc.3
|
|
111
|
+
- @akinon/pz-checkout-gift-pack@1.48.0-rc.3
|
|
112
|
+
- @akinon/pz-one-click-checkout@1.48.0-rc.3
|
|
113
|
+
- @akinon/pz-basket-gift-pack@1.48.0-rc.3
|
|
114
|
+
- @akinon/pz-click-collect@1.48.0-rc.3
|
|
115
|
+
- @akinon/pz-masterpass@1.48.0-rc.3
|
|
116
|
+
- @akinon/pz-akifast@1.48.0-rc.3
|
|
117
|
+
- @akinon/pz-gpay@1.48.0-rc.3
|
|
118
|
+
- @akinon/pz-b2b@1.48.0-rc.3
|
|
119
|
+
- @akinon/pz-bkm@1.48.0-rc.3
|
|
120
|
+
- @akinon/pz-otp@1.48.0-rc.3
|
|
121
|
+
- @akinon/pz-pay-on-delivery@1.48.0-rc.3
|
|
122
|
+
- @akinon/pz-credit-payment@1.48.0-rc.3
|
|
123
|
+
|
|
124
|
+
## 1.48.0-rc.2
|
|
125
|
+
|
|
126
|
+
### Minor Changes
|
|
127
|
+
|
|
128
|
+
- 2e6104d: ZERO-2888:Edit the numbering in the pagination and the visibility of the prev and next buttons
|
|
129
|
+
|
|
130
|
+
### Patch Changes
|
|
131
|
+
|
|
132
|
+
- Updated dependencies [2e6104d]
|
|
133
|
+
- @akinon/next@1.48.0-rc.2
|
|
134
|
+
- @akinon/pz-akifast@1.48.0-rc.2
|
|
135
|
+
- @akinon/pz-b2b@1.48.0-rc.2
|
|
136
|
+
- @akinon/pz-basket-gift-pack@1.48.0-rc.2
|
|
137
|
+
- @akinon/pz-bkm@1.48.0-rc.2
|
|
138
|
+
- @akinon/pz-checkout-gift-pack@1.48.0-rc.2
|
|
139
|
+
- @akinon/pz-click-collect@1.48.0-rc.2
|
|
140
|
+
- @akinon/pz-credit-payment@1.48.0-rc.2
|
|
141
|
+
- @akinon/pz-gpay@1.48.0-rc.2
|
|
142
|
+
- @akinon/pz-masterpass@1.48.0-rc.2
|
|
143
|
+
- @akinon/pz-one-click-checkout@1.48.0-rc.2
|
|
144
|
+
- @akinon/pz-otp@1.48.0-rc.2
|
|
145
|
+
- @akinon/pz-pay-on-delivery@1.48.0-rc.2
|
|
146
|
+
|
|
3
147
|
## 1.48.0-rc.1
|
|
4
148
|
|
|
5
149
|
### Patch Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "projectzeronext",
|
|
3
|
-
"version": "1.48.0-rc.
|
|
3
|
+
"version": "1.48.0-rc.3",
|
|
4
4
|
"private": true,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -22,19 +22,19 @@
|
|
|
22
22
|
"prestart": "pz-prestart"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@akinon/next": "1.48.0-rc.
|
|
26
|
-
"@akinon/pz-akifast": "1.48.0-rc.
|
|
27
|
-
"@akinon/pz-b2b": "1.48.0-rc.
|
|
28
|
-
"@akinon/pz-basket-gift-pack": "1.48.0-rc.
|
|
29
|
-
"@akinon/pz-bkm": "1.48.0-rc.
|
|
30
|
-
"@akinon/pz-checkout-gift-pack": "1.48.0-rc.
|
|
31
|
-
"@akinon/pz-click-collect": "1.48.0-rc.
|
|
32
|
-
"@akinon/pz-credit-payment": "1.48.0-rc.
|
|
33
|
-
"@akinon/pz-gpay": "1.48.0-rc.
|
|
34
|
-
"@akinon/pz-masterpass": "1.48.0-rc.
|
|
35
|
-
"@akinon/pz-one-click-checkout": "1.48.0-rc.
|
|
36
|
-
"@akinon/pz-otp": "1.48.0-rc.
|
|
37
|
-
"@akinon/pz-pay-on-delivery": "1.48.0-rc.
|
|
25
|
+
"@akinon/next": "1.48.0-rc.3",
|
|
26
|
+
"@akinon/pz-akifast": "1.48.0-rc.3",
|
|
27
|
+
"@akinon/pz-b2b": "1.48.0-rc.3",
|
|
28
|
+
"@akinon/pz-basket-gift-pack": "1.48.0-rc.3",
|
|
29
|
+
"@akinon/pz-bkm": "1.48.0-rc.3",
|
|
30
|
+
"@akinon/pz-checkout-gift-pack": "1.48.0-rc.3",
|
|
31
|
+
"@akinon/pz-click-collect": "1.48.0-rc.3",
|
|
32
|
+
"@akinon/pz-credit-payment": "1.48.0-rc.3",
|
|
33
|
+
"@akinon/pz-gpay": "1.48.0-rc.3",
|
|
34
|
+
"@akinon/pz-masterpass": "1.48.0-rc.3",
|
|
35
|
+
"@akinon/pz-one-click-checkout": "1.48.0-rc.3",
|
|
36
|
+
"@akinon/pz-otp": "1.48.0-rc.3",
|
|
37
|
+
"@akinon/pz-pay-on-delivery": "1.48.0-rc.3",
|
|
38
38
|
"@hookform/resolvers": "2.9.0",
|
|
39
39
|
"@next/third-parties": "14.1.0",
|
|
40
40
|
"@react-google-maps/api": "2.17.1",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"yup": "0.32.11"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@akinon/eslint-plugin-projectzero": "1.48.0-rc.
|
|
61
|
+
"@akinon/eslint-plugin-projectzero": "1.48.0-rc.3",
|
|
62
62
|
"@semantic-release/changelog": "6.0.2",
|
|
63
63
|
"@semantic-release/exec": "6.0.3",
|
|
64
64
|
"@semantic-release/git": "10.0.1",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"stylelint-config-standard": "25.0.0",
|
|
95
95
|
"stylelint-scss": "4.2.0",
|
|
96
96
|
"stylelint-selector-bem-pattern": "2.1.1",
|
|
97
|
-
"tailwindcss": "3.4.
|
|
97
|
+
"tailwindcss": "3.4.12",
|
|
98
98
|
"ts-jest": "29.1.1",
|
|
99
99
|
"ts-node": "10.7.0",
|
|
100
100
|
"typescript": "5.2.2"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { PaginationProps } from '@theme/components/types';
|
|
3
3
|
import { twMerge } from 'tailwind-merge';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
|
-
import {
|
|
5
|
+
import { Button } from '@theme/components';
|
|
6
6
|
import usePagination from '@akinon/next/hooks/use-pagination';
|
|
7
7
|
import { useLocalization } from '@akinon/next/hooks';
|
|
8
8
|
import { useRouter } from '@akinon/next/hooks';
|
|
@@ -92,9 +92,7 @@ export const Pagination = (props: PaginationProps) => {
|
|
|
92
92
|
}
|
|
93
93
|
}, [numberOfPages, page, pageList, threshold]);
|
|
94
94
|
|
|
95
|
-
const handleClick = (
|
|
96
|
-
e.preventDefault();
|
|
97
|
-
|
|
95
|
+
const handleClick = (url: string) => {
|
|
98
96
|
const newUrl = new URL(url, window.location.origin);
|
|
99
97
|
const page = newUrl.searchParams.get('page');
|
|
100
98
|
|
|
@@ -129,7 +127,7 @@ export const Pagination = (props: PaginationProps) => {
|
|
|
129
127
|
if (type === 'list') {
|
|
130
128
|
createListItems();
|
|
131
129
|
}
|
|
132
|
-
}, []);
|
|
130
|
+
}, [createListItems, type]);
|
|
133
131
|
|
|
134
132
|
useEffect(() => {
|
|
135
133
|
if (total && total !== paginationTotal) {
|
|
@@ -200,9 +198,8 @@ export const Pagination = (props: PaginationProps) => {
|
|
|
200
198
|
>
|
|
201
199
|
{prev && currentPage !== 1 && (
|
|
202
200
|
<li>
|
|
203
|
-
<
|
|
204
|
-
onClick={(
|
|
205
|
-
href={prev}
|
|
201
|
+
<button
|
|
202
|
+
onClick={() => handleClick(prev)}
|
|
206
203
|
className={twMerge(
|
|
207
204
|
'flex cursor-pointer text-sm px-2',
|
|
208
205
|
prevClassName
|
|
@@ -212,16 +209,15 @@ export const Pagination = (props: PaginationProps) => {
|
|
|
212
209
|
<span className="hidden lg:inline-block ms-4">
|
|
213
210
|
{t('category.pagination.previous')}
|
|
214
211
|
</span>
|
|
215
|
-
</
|
|
212
|
+
</button>
|
|
216
213
|
</li>
|
|
217
214
|
)}
|
|
218
215
|
|
|
219
216
|
{paginationItems.map((item, i) => (
|
|
220
217
|
<li key={i}>
|
|
221
218
|
{item?.url != '#' ? (
|
|
222
|
-
<
|
|
223
|
-
onClick={(
|
|
224
|
-
href={item.url}
|
|
219
|
+
<button
|
|
220
|
+
onClick={() => handleClick(item.url)}
|
|
225
221
|
className={twMerge(
|
|
226
222
|
clsx(
|
|
227
223
|
'text-xs px-2 cursor-pointer',
|
|
@@ -234,7 +230,7 @@ export const Pagination = (props: PaginationProps) => {
|
|
|
234
230
|
)}
|
|
235
231
|
>
|
|
236
232
|
{item?.page}
|
|
237
|
-
</
|
|
233
|
+
</button>
|
|
238
234
|
) : (
|
|
239
235
|
<span className="cursor-default text-xs flex items-center justify-center">
|
|
240
236
|
{item?.page}
|
|
@@ -245,9 +241,8 @@ export const Pagination = (props: PaginationProps) => {
|
|
|
245
241
|
|
|
246
242
|
{showNext && (
|
|
247
243
|
<li>
|
|
248
|
-
<
|
|
249
|
-
onClick={(
|
|
250
|
-
href={next}
|
|
244
|
+
<button
|
|
245
|
+
onClick={() => handleClick(next)}
|
|
251
246
|
className={twMerge(
|
|
252
247
|
'flex cursor-pointer text-xs px-2',
|
|
253
248
|
nextClassName
|
|
@@ -257,7 +252,7 @@ export const Pagination = (props: PaginationProps) => {
|
|
|
257
252
|
{t('category.pagination.next')}
|
|
258
253
|
</span>
|
|
259
254
|
<span>></span>
|
|
260
|
-
</
|
|
255
|
+
</button>
|
|
261
256
|
</li>
|
|
262
257
|
)}
|
|
263
258
|
</ul>
|
|
@@ -22,17 +22,28 @@ const CategoryActiveFilters = () => {
|
|
|
22
22
|
const handleRemoveFilter = ({ facet, choice }) => {
|
|
23
23
|
if (facet.widget_type === WIDGET_TYPE.category) {
|
|
24
24
|
dispatch(removeCategoryFacet({ facet, choice }));
|
|
25
|
-
|
|
25
|
+
} else {
|
|
26
|
+
dispatch(toggleFacet({ facet, choice }));
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
30
|
+
urlSearchParams.delete(facet.search_key);
|
|
31
|
+
router.replace(pathname + '?' + urlSearchParams.toString());
|
|
29
32
|
};
|
|
30
33
|
|
|
31
34
|
const url = useMemo(() => {
|
|
32
|
-
const facetSearchParams =
|
|
33
|
-
|
|
35
|
+
const facetSearchParams = convertFacetSearchParams(selectedFacets);
|
|
36
|
+
const urlSearchParams = new URLSearchParams(searchParams.toString());
|
|
34
37
|
|
|
35
|
-
const
|
|
38
|
+
for (const key of Array.from(urlSearchParams.keys())) {
|
|
39
|
+
if (facetSearchParams.has(key)) {
|
|
40
|
+
urlSearchParams.delete(key);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
for (const [key, value] of Array.from(facetSearchParams.entries())) {
|
|
45
|
+
urlSearchParams.append(key, value);
|
|
46
|
+
}
|
|
36
47
|
|
|
37
48
|
const searchText = searchParams.get('search_text');
|
|
38
49
|
const page = searchParams.get('page');
|
|
@@ -53,7 +64,6 @@ const CategoryActiveFilters = () => {
|
|
|
53
64
|
|
|
54
65
|
useEffect(() => {
|
|
55
66
|
router.push(url);
|
|
56
|
-
|
|
57
67
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
58
68
|
}, [url]);
|
|
59
69
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
2
|
import { useAppDispatch } from '@akinon/next/redux/hooks';
|
|
3
3
|
import { Facet, FacetChoice } from '@akinon/next/types';
|
|
4
|
-
import { Accordion, Radio, Checkbox } from '../../../components';
|
|
4
|
+
import { Accordion, Radio, Checkbox, LoaderSpinner } from '../../../components';
|
|
5
5
|
import { WIDGET_TYPE } from '../../../types';
|
|
6
6
|
import { SizeFilter } from './size-filter';
|
|
7
7
|
import { toggleFacet } from '@theme/redux/reducers/category';
|
|
8
8
|
import { commonProductAttributes } from '@theme/settings';
|
|
9
9
|
import { useRouter } from '@akinon/next/hooks';
|
|
10
|
+
import { usePathname } from 'next/navigation';
|
|
11
|
+
import { useState } from 'react';
|
|
10
12
|
|
|
11
13
|
const COMPONENT_TYPES = {
|
|
12
14
|
[WIDGET_TYPE.category]: Radio,
|
|
@@ -19,6 +21,8 @@ const sizeKey = commonProductAttributes.find(
|
|
|
19
21
|
|
|
20
22
|
interface Props {
|
|
21
23
|
facet: Facet;
|
|
24
|
+
isPending: boolean;
|
|
25
|
+
startTransition: (callback: () => void) => void;
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
const sortByPredefinedOrder = (
|
|
@@ -78,16 +82,33 @@ const getComponentByWidgetType = (widgetType: string, facetKey: string) => {
|
|
|
78
82
|
return COMPONENT_TYPES[widgetType] || COMPONENT_TYPES[WIDGET_TYPE.category];
|
|
79
83
|
};
|
|
80
84
|
|
|
81
|
-
export const FilterItem = ({ facet }: Props) => {
|
|
85
|
+
export const FilterItem = ({ facet, isPending, startTransition }: Props) => {
|
|
82
86
|
const dispatch = useAppDispatch();
|
|
83
87
|
const router = useRouter();
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
const pathname = usePathname();
|
|
89
|
+
|
|
90
|
+
const [pendingChoice, setPendingChoice] = useState<string | null>(null);
|
|
91
|
+
|
|
92
|
+
const handleSelectFilter = ({
|
|
93
|
+
facet,
|
|
94
|
+
choice
|
|
95
|
+
}: {
|
|
96
|
+
facet: Facet;
|
|
97
|
+
choice: FacetChoice;
|
|
98
|
+
}) => {
|
|
99
|
+
setPendingChoice(choice.label);
|
|
100
|
+
startTransition(() => {
|
|
101
|
+
if (facet.key === 'category_ids') {
|
|
102
|
+
router.push(choice.url);
|
|
103
|
+
} else {
|
|
104
|
+
dispatch(toggleFacet({ facet, choice }));
|
|
105
|
+
}
|
|
106
|
+
setPendingChoice(null);
|
|
107
|
+
|
|
108
|
+
const urlSearchParams = new URLSearchParams(window.location.search);
|
|
109
|
+
urlSearchParams.delete(facet.search_key);
|
|
110
|
+
router.replace(pathname + '?' + urlSearchParams.toString());
|
|
111
|
+
});
|
|
91
112
|
};
|
|
92
113
|
|
|
93
114
|
const Component = getComponentByWidgetType(facet.widget_type, facet.key);
|
|
@@ -107,23 +128,34 @@ export const FilterItem = ({ facet }: Props) => {
|
|
|
107
128
|
})}
|
|
108
129
|
>
|
|
109
130
|
{choices.map((choice, index) => (
|
|
110
|
-
<
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
131
|
+
<div key={choice.label} className="relative">
|
|
132
|
+
<Component
|
|
133
|
+
key={choice.label}
|
|
134
|
+
data={choice}
|
|
135
|
+
name={facet.key}
|
|
136
|
+
onChange={() => handleSelectFilter({ facet, choice })}
|
|
137
|
+
onClick={() =>
|
|
138
|
+
facet.key === sizeKey && handleSelectFilter({ facet, choice })
|
|
139
|
+
}
|
|
140
|
+
checked={choice.is_selected}
|
|
141
|
+
data-testid={`${choice.label.trim()}`}
|
|
142
|
+
disabled={isPending}
|
|
122
143
|
>
|
|
123
|
-
{choice.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
144
|
+
{choice.label} (
|
|
145
|
+
<span
|
|
146
|
+
data-testid={`filter-count-${facet.name.toLowerCase()}-${index}`}
|
|
147
|
+
>
|
|
148
|
+
{choice.quantity}
|
|
149
|
+
</span>
|
|
150
|
+
)
|
|
151
|
+
</Component>
|
|
152
|
+
|
|
153
|
+
{isPending && pendingChoice === choice.label && (
|
|
154
|
+
<div className="absolute inset-0 flex items-center justify-center z-50">
|
|
155
|
+
<LoaderSpinner />
|
|
156
|
+
</div>
|
|
157
|
+
)}
|
|
158
|
+
</div>
|
|
127
159
|
))}
|
|
128
160
|
</div>
|
|
129
161
|
</Accordion>
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
|
|
5
4
|
import { Button, Icon } from '@theme/components';
|
|
6
5
|
import { useLocalization } from '@akinon/next/hooks';
|
|
7
6
|
import { useAppDispatch, useAppSelector } from '@akinon/next/redux/hooks';
|
|
8
7
|
import { resetSelectedFacets } from '@theme/redux/reducers/category';
|
|
9
8
|
import CategoryActiveFilters from '@theme/views/category/category-active-filters';
|
|
10
|
-
import { useMemo } from 'react';
|
|
9
|
+
import { useMemo, useState, useTransition } from 'react';
|
|
11
10
|
import { FilterItem } from './filter-item';
|
|
12
11
|
|
|
13
12
|
interface Props {
|
|
@@ -21,12 +20,11 @@ export const Filters = (props: Props) => {
|
|
|
21
20
|
const { t } = useLocalization();
|
|
22
21
|
const { isMenuOpen, setIsMenuOpen } = props;
|
|
23
22
|
|
|
23
|
+
const [isPending, startTransition] = useTransition();
|
|
24
|
+
|
|
24
25
|
const haveFilter = useMemo(() => {
|
|
25
|
-
return (
|
|
26
|
-
|
|
27
|
-
(facet) =>
|
|
28
|
-
facet.data.choices.filter((choice) => choice.is_selected).length > 0
|
|
29
|
-
).length > 0
|
|
26
|
+
return facets.some((facet) =>
|
|
27
|
+
facet.data.choices.some((choice) => choice.is_selected)
|
|
30
28
|
);
|
|
31
29
|
}, [facets]);
|
|
32
30
|
|
|
@@ -51,12 +49,22 @@ export const Filters = (props: Props) => {
|
|
|
51
49
|
<span className="text-sm">1 {t('category.filters.results')}</span>
|
|
52
50
|
<span>{t('category.filters.ready_to_wear')}</span>
|
|
53
51
|
</div>
|
|
52
|
+
|
|
54
53
|
{facets.map((facet) => {
|
|
55
|
-
return
|
|
54
|
+
return (
|
|
55
|
+
<FilterItem
|
|
56
|
+
key={facet.key}
|
|
57
|
+
facet={facet}
|
|
58
|
+
isPending={isPending}
|
|
59
|
+
startTransition={startTransition}
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
56
62
|
})}
|
|
63
|
+
|
|
57
64
|
<div className="lg:hidden">
|
|
58
65
|
<CategoryActiveFilters />
|
|
59
66
|
</div>
|
|
67
|
+
|
|
60
68
|
{haveFilter && (
|
|
61
69
|
<div className="lg:hidden">
|
|
62
70
|
<Button
|