@graphcommerce/magento-cart 8.1.0-canary.8 → 9.0.0-canary.100

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.
Files changed (31) hide show
  1. package/Api/CartItemCountChanged.graphql +1 -1
  2. package/CHANGELOG.md +247 -54
  3. package/Config.graphqls +17 -0
  4. package/components/ApolloCartError/ApolloCartErrorAlert.tsx +1 -46
  5. package/components/CartAddress/CartAddress.graphql +1 -0
  6. package/components/CartAgreementsForm/CartAgreementsForm.tsx +60 -33
  7. package/components/CartFab/CartFab.tsx +7 -1
  8. package/components/CartStartCheckout/CartStartCheckout.graphql +1 -1
  9. package/components/CartStartCheckout/CartStartCheckout.tsx +23 -7
  10. package/components/CartStartCheckout/CartStartCheckoutLinkOrButton.tsx +4 -2
  11. package/components/CartTotals/CartTotals.graphql +8 -4
  12. package/components/CartTotals/CartTotals.tsx +9 -6
  13. package/components/EmptyCart/EmptyCart.tsx +8 -4
  14. package/components/InlineAccount/InlineAccount.tsx +6 -6
  15. package/components/OrderSucces/OrderSuccesPage.graphql +1 -1
  16. package/hooks/index.ts +5 -3
  17. package/hooks/useCartPermissions.ts +21 -0
  18. package/hooks/useCartQuery.ts +24 -3
  19. package/hooks/useCheckoutPermissions.ts +21 -0
  20. package/hooks/useFormGqlMutationCart.ts +40 -3
  21. package/index.ts +4 -3
  22. package/link/{createCartErrorLink.ts → cartLink.ts} +60 -4
  23. package/link/isProtectedCartOperation.ts +5 -0
  24. package/package.json +16 -15
  25. package/plugins/MagentoCartGraphqlProvider.tsx +15 -3
  26. package/plugins/useSignInFormMergeCart.ts +8 -7
  27. package/typePolicies.ts +1 -0
  28. package/utils/cartPermissions.ts +23 -0
  29. package/utils/checkoutPermissions.ts +13 -0
  30. package/utils/index.ts +2 -0
  31. package/hooks/CurrentCartId.graphqls +0 -12
@@ -1,4 +1,4 @@
1
- fragment CartItemCountChanged on Cart @injectable {
1
+ fragment CartItemCountChanged on Cart {
2
2
  __typename
3
3
  id
4
4
  total_quantity
package/CHANGELOG.md CHANGED
@@ -1,11 +1,226 @@
1
1
  # Change Log
2
2
 
3
+ ## 9.0.0-canary.100
4
+
5
+ ## 9.0.0-canary.99
6
+
7
+ ## 9.0.0-canary.98
8
+
9
+ ## 9.0.0-canary.97
10
+
11
+ ## 9.0.0-canary.96
12
+
13
+ ## 9.0.0-canary.95
14
+
15
+ ## 9.0.0-canary.94
16
+
17
+ ## 9.0.0-canary.93
18
+
19
+ ## 9.0.0-canary.92
20
+
21
+ ## 9.0.0-canary.91
22
+
23
+ ## 9.0.0-canary.90
24
+
25
+ ## 9.0.0-canary.89
26
+
27
+ ## 9.0.0-canary.88
28
+
29
+ ## 9.0.0-canary.87
30
+
31
+ ## 9.0.0-canary.86
32
+
33
+ ## 9.0.0-canary.85
34
+
35
+ ## 9.0.0-canary.84
36
+
37
+ ## 9.0.0-canary.83
38
+
39
+ ## 9.0.0-canary.82
40
+
41
+ ### Minor Changes
42
+
43
+ - [#2366](https://github.com/graphcommerce-org/graphcommerce/pull/2366) [`3612c99`](https://github.com/graphcommerce-org/graphcommerce/commit/3612c994b80bb3b1bc02de10668f69a332402dc4) - Add `permissions` config so the website or store can be configurated to run in different modes. ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
44
+
45
+ ## 9.0.0-canary.81
46
+
47
+ ## 9.0.0-canary.80
48
+
49
+ ## 9.0.0-canary.79
50
+
51
+ ## 9.0.0-canary.78
52
+
53
+ ## 9.0.0-canary.77
54
+
55
+ ## 9.0.0-canary.76
56
+
57
+ ## 9.0.0-canary.75
58
+
59
+ ## 9.0.0-canary.74
60
+
61
+ ## 9.0.0-canary.73
62
+
63
+ ## 9.0.0-canary.72
64
+
65
+ ## 9.0.0-canary.71
66
+
67
+ ## 9.0.0-canary.70
68
+
69
+ ## 9.0.0-canary.69
70
+
71
+ ### Patch Changes
72
+
73
+ - [#2338](https://github.com/graphcommerce-org/graphcommerce/pull/2338) [`6984f8c`](https://github.com/graphcommerce-org/graphcommerce/commit/6984f8ce94433963d7bab0e1949c1737767e17ba) - Pass sx props to EmptyCart component ([@JoshuaS98](https://github.com/JoshuaS98))
74
+
75
+ ## 9.0.0-canary.68
76
+
77
+ ## 9.0.0-canary.67
78
+
79
+ ## 9.0.0-canary.66
80
+
81
+ ## 9.0.0-canary.65
82
+
83
+ ## 9.0.0-canary.64
84
+
85
+ ## 9.0.0-canary.63
86
+
87
+ ## 9.0.0-canary.62
88
+
89
+ ## 9.0.0-canary.61
90
+
91
+ ## 9.0.0-canary.60
92
+
93
+ ## 9.0.0-canary.59
94
+
95
+ ## 9.0.0-canary.58
96
+
97
+ ## 9.0.0-canary.57
98
+
99
+ ## 9.0.0-canary.56
100
+
101
+ ## 9.0.0-canary.55
102
+
103
+ ## 9.0.0-canary.54
104
+
105
+ ## 8.1.0-canary.53
106
+
107
+ ## 8.1.0-canary.52
108
+
109
+ ## 8.1.0-canary.51
110
+
111
+ ## 8.1.0-canary.50
112
+
113
+ ## 8.1.0-canary.49
114
+
115
+ ## 8.1.0-canary.48
116
+
117
+ ## 8.1.0-canary.47
118
+
119
+ ## 8.1.0-canary.46
120
+
121
+ ## 8.1.0-canary.45
122
+
123
+ ### Patch Changes
124
+
125
+ - [#2216](https://github.com/graphcommerce-org/graphcommerce/pull/2216) [`2faebf1`](https://github.com/graphcommerce-org/graphcommerce/commit/2faebf16fbda95390872ac0debe979fa570ed904) - When signing in make sure the cart isn't merged if the login is unsuccesful ([@paales](https://github.com/paales))
126
+
127
+ ## 8.1.0-canary.44
128
+
129
+ ## 8.1.0-canary.43
130
+
131
+ ## 8.1.0-canary.42
132
+
133
+ ## 8.1.0-canary.41
134
+
135
+ ## 8.1.0-canary.40
136
+
137
+ ## 8.1.0-canary.39
138
+
139
+ ## 8.1.0-canary.38
140
+
141
+ ### Minor Changes
142
+
143
+ - [#2305](https://github.com/graphcommerce-org/graphcommerce/pull/2305) [`77e8297`](https://github.com/graphcommerce-org/graphcommerce/commit/77e82976816994336c616208a651cb18ce9ea270) - Add company and vat fields to shipping and billing forms ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
144
+
145
+ ### Patch Changes
146
+
147
+ - [#2305](https://github.com/graphcommerce-org/graphcommerce/pull/2305) [`77e8297`](https://github.com/graphcommerce-org/graphcommerce/commit/77e82976816994336c616208a651cb18ce9ea270) - Fix bug with persist not applying saved changes by moving <FromPersist/> below the form components ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
148
+
149
+ ## 8.1.0-canary.37
150
+
151
+ ## 8.1.0-canary.36
152
+
153
+ ## 8.1.0-canary.35
154
+
155
+ ### Patch Changes
156
+
157
+ - [#2301](https://github.com/graphcommerce-org/graphcommerce/pull/2301) [`13d0649`](https://github.com/graphcommerce-org/graphcommerce/commit/13d06498d121f93b52c25930e50aa3b0bd12a818) - Created a new EmailElement component to make re-use easier ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
158
+
159
+ ## 8.1.0-canary.34
160
+
161
+ ### Minor Changes
162
+
163
+ - [#2303](https://github.com/graphcommerce-org/graphcommerce/pull/2303) [`f407e96`](https://github.com/graphcommerce-org/graphcommerce/commit/f407e961868683a257c8f7fe8ceb588fb825db9b) - Get shippingMethodPrices from selected shipping method if supported on the magento version ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
164
+
165
+ ## 8.1.0-canary.33
166
+
167
+ ## 8.1.0-canary.32
168
+
169
+ ## 8.1.0-canary.31
170
+
171
+ ## 8.1.0-canary.30
172
+
173
+ ## 8.1.0-canary.29
174
+
175
+ ## 8.1.0-canary.28
176
+
177
+ ## 8.1.0-canary.27
178
+
179
+ ## 8.1.0-canary.26
180
+
181
+ ## 8.1.0-canary.25
182
+
183
+ ### Patch Changes
184
+
185
+ - [#2266](https://github.com/graphcommerce-org/graphcommerce/pull/2266) [`0d1fe7a`](https://github.com/graphcommerce-org/graphcommerce/commit/0d1fe7a26ed2d18510c8767795294654c478fb88) - Enable the use of one or more anchor links within the 'checkbox_text' field and customize their paths. ([@carlocarels90](https://github.com/carlocarels90))
186
+
187
+ ## 8.1.0-canary.24
188
+
189
+ ## 8.1.0-canary.23
190
+
191
+ ## 8.1.0-canary.22
192
+
193
+ ## 8.1.0-canary.21
194
+
195
+ ## 8.1.0-canary.20
196
+
197
+ ## 8.1.0-canary.19
198
+
199
+ ## 8.1.0-canary.18
200
+
201
+ ## 8.1.0-canary.17
202
+
203
+ ## 8.1.0-canary.16
204
+
205
+ ## 8.1.0-canary.15
206
+
207
+ ## 8.1.0-canary.14
208
+
209
+ ## 8.1.0-canary.13
210
+
211
+ ## 8.1.0-canary.12
212
+
213
+ ## 8.1.0-canary.11
214
+
215
+ ## 8.1.0-canary.10
216
+
217
+ ## 8.1.0-canary.9
218
+
3
219
  ## 8.1.0-canary.8
4
220
 
5
221
  ### Patch Changes
6
222
 
7
- - [#2247](https://github.com/graphcommerce-org/graphcommerce/pull/2247) [`a56a7c6`](https://github.com/graphcommerce-org/graphcommerce/commit/a56a7c67cf27dfb91bf763a873beeec562ab3156) - Solve an issue where the cart would be sometimes undefined, but Partial was too eleborate
8
- ([@paales](https://github.com/paales))
223
+ - [#2247](https://github.com/graphcommerce-org/graphcommerce/pull/2247) [`a56a7c6`](https://github.com/graphcommerce-org/graphcommerce/commit/a56a7c67cf27dfb91bf763a873beeec562ab3156) - Solve an issue where the cart would be sometimes undefined, but Partial was too eleborate ([@paales](https://github.com/paales))
9
224
 
10
225
  ## 8.1.0-canary.7
11
226
 
@@ -21,11 +236,9 @@
21
236
 
22
237
  ### Patch Changes
23
238
 
24
- - [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`0767bc4`](https://github.com/graphcommerce-org/graphcommerce/commit/0767bc40f7b596209f24ca4e745ff0441f3275c9) - Upgrade input components to no longer use muiRegister, which improves INP scores
25
- ([@FrankHarland](https://github.com/FrankHarland))
239
+ - [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`0767bc4`](https://github.com/graphcommerce-org/graphcommerce/commit/0767bc40f7b596209f24ca4e745ff0441f3275c9) - Upgrade input components to no longer use muiRegister, which improves INP scores ([@FrankHarland](https://github.com/FrankHarland))
26
240
 
27
- - [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`530076e`](https://github.com/graphcommerce-org/graphcommerce/commit/530076e3664703cb8b577b7fcf1998a420819f60) - Moved all usages of useFormPersist to the <FormPersist/> component to prevent rerenders.
28
- ([@FrankHarland](https://github.com/FrankHarland))
241
+ - [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`530076e`](https://github.com/graphcommerce-org/graphcommerce/commit/530076e3664703cb8b577b7fcf1998a420819f60) - Moved all usages of useFormPersist to the <FormPersist/> component to prevent rerenders. ([@FrankHarland](https://github.com/FrankHarland))
29
242
 
30
243
  ## 8.0.6-canary.1
31
244
 
@@ -59,8 +272,7 @@
59
272
 
60
273
  ### Patch Changes
61
274
 
62
- - [#2221](https://github.com/graphcommerce-org/graphcommerce/pull/2221) [`0ba1fdc`](https://github.com/graphcommerce-org/graphcommerce/commit/0ba1fdc9a2d005f47cd1725fe723e77da4cc5b9d) - After a user just logged in the checkout, the useFormGqlMutationCart would still run even though the cart was locked.
63
- ([@paales](https://github.com/paales))
275
+ - [#2221](https://github.com/graphcommerce-org/graphcommerce/pull/2221) [`0ba1fdc`](https://github.com/graphcommerce-org/graphcommerce/commit/0ba1fdc9a2d005f47cd1725fe723e77da4cc5b9d) - After a user just logged in the checkout, the useFormGqlMutationCart would still run even though the cart was locked. ([@paales](https://github.com/paales))
64
276
 
65
277
  ## 8.0.4-canary.1
66
278
 
@@ -68,21 +280,17 @@
68
280
 
69
281
  ### Patch Changes
70
282
 
71
- - [#2221](https://github.com/graphcommerce-org/graphcommerce/pull/2221) [`0ba1fdc`](https://github.com/graphcommerce-org/graphcommerce/commit/0ba1fdc9a2d005f47cd1725fe723e77da4cc5b9d) - After a user just logged in the checkout, the useFormGqlMutationCart would still run even though the cart was locked.
72
- ([@paales](https://github.com/paales))
283
+ - [#2221](https://github.com/graphcommerce-org/graphcommerce/pull/2221) [`0ba1fdc`](https://github.com/graphcommerce-org/graphcommerce/commit/0ba1fdc9a2d005f47cd1725fe723e77da4cc5b9d) - After a user just logged in the checkout, the useFormGqlMutationCart would still run even though the cart was locked. ([@paales](https://github.com/paales))
73
284
 
74
285
  ## 8.0.3
75
286
 
76
287
  ### Patch Changes
77
288
 
78
- - [#2205](https://github.com/graphcommerce-org/graphcommerce/pull/2205) [`d67c89d`](https://github.com/graphcommerce-org/graphcommerce/commit/d67c89d464a60f0e2618dab670b63a39f6291341) - Deprecate the allowUrl option for useCartQuery, it was already enabled by default and should never be set to false.
79
- ([@paales](https://github.com/paales))
289
+ - [#2205](https://github.com/graphcommerce-org/graphcommerce/pull/2205) [`d67c89d`](https://github.com/graphcommerce-org/graphcommerce/commit/d67c89d464a60f0e2618dab670b63a39f6291341) - Deprecate the allowUrl option for useCartQuery, it was already enabled by default and should never be set to false. ([@paales](https://github.com/paales))
80
290
 
81
- - [#2205](https://github.com/graphcommerce-org/graphcommerce/pull/2205) [`3fbf3da`](https://github.com/graphcommerce-org/graphcommerce/commit/3fbf3da8a67f2fbaa7fa974a37cbbf34613844e4) - Solve an issue where the user would be presented with the Session expired dialog when the user would be logging in during the checkout process.
82
- ([@paales](https://github.com/paales))
291
+ - [#2205](https://github.com/graphcommerce-org/graphcommerce/pull/2205) [`3fbf3da`](https://github.com/graphcommerce-org/graphcommerce/commit/3fbf3da8a67f2fbaa7fa974a37cbbf34613844e4) - Solve an issue where the user would be presented with the Session expired dialog when the user would be logging in during the checkout process. ([@paales](https://github.com/paales))
83
292
 
84
- - [#2207](https://github.com/graphcommerce-org/graphcommerce/pull/2207) [`9876b13`](https://github.com/graphcommerce-org/graphcommerce/commit/9876b139b2c12c860a16af97eddea761d1059110) - Remove redundant query on the success page for logged in customers
85
- ([@paales](https://github.com/paales))
293
+ - [#2207](https://github.com/graphcommerce-org/graphcommerce/pull/2207) [`9876b13`](https://github.com/graphcommerce-org/graphcommerce/commit/9876b139b2c12c860a16af97eddea761d1059110) - Remove redundant query on the success page for logged in customers ([@paales](https://github.com/paales))
86
294
 
87
295
  ## 8.0.3-canary.6
88
296
 
@@ -96,18 +304,15 @@
96
304
 
97
305
  ### Patch Changes
98
306
 
99
- - [#2205](https://github.com/graphcommerce-org/graphcommerce/pull/2205) [`d67c89d`](https://github.com/graphcommerce-org/graphcommerce/commit/d67c89d464a60f0e2618dab670b63a39f6291341) - Deprecate the allowUrl option for useCartQuery, it was already enabled by default and should never be set to false.
100
- ([@paales](https://github.com/paales))
307
+ - [#2205](https://github.com/graphcommerce-org/graphcommerce/pull/2205) [`d67c89d`](https://github.com/graphcommerce-org/graphcommerce/commit/d67c89d464a60f0e2618dab670b63a39f6291341) - Deprecate the allowUrl option for useCartQuery, it was already enabled by default and should never be set to false. ([@paales](https://github.com/paales))
101
308
 
102
- - [#2205](https://github.com/graphcommerce-org/graphcommerce/pull/2205) [`3fbf3da`](https://github.com/graphcommerce-org/graphcommerce/commit/3fbf3da8a67f2fbaa7fa974a37cbbf34613844e4) - Solve an issue where the user would be presented with the Session expired dialog when the user would be logging in during the checkout process.
103
- ([@paales](https://github.com/paales))
309
+ - [#2205](https://github.com/graphcommerce-org/graphcommerce/pull/2205) [`3fbf3da`](https://github.com/graphcommerce-org/graphcommerce/commit/3fbf3da8a67f2fbaa7fa974a37cbbf34613844e4) - Solve an issue where the user would be presented with the Session expired dialog when the user would be logging in during the checkout process. ([@paales](https://github.com/paales))
104
310
 
105
311
  ## 8.0.3-canary.1
106
312
 
107
313
  ### Patch Changes
108
314
 
109
- - [#2207](https://github.com/graphcommerce-org/graphcommerce/pull/2207) [`9876b13`](https://github.com/graphcommerce-org/graphcommerce/commit/9876b139b2c12c860a16af97eddea761d1059110) - Remove redundant query on the success page for logged in customers
110
- ([@paales](https://github.com/paales))
315
+ - [#2207](https://github.com/graphcommerce-org/graphcommerce/pull/2207) [`9876b13`](https://github.com/graphcommerce-org/graphcommerce/commit/9876b139b2c12c860a16af97eddea761d1059110) - Remove redundant query on the success page for logged in customers ([@paales](https://github.com/paales))
111
316
 
112
317
  ## 8.0.3-canary.0
113
318
 
@@ -137,38 +342,29 @@
137
342
 
138
343
  ### Minor Changes
139
344
 
140
- - [#2075](https://github.com/graphcommerce-org/graphcommerce/pull/2075) [`34dee45`](https://github.com/graphcommerce-org/graphcommerce/commit/34dee456ef686174b62e604911a0ba84cbd3d002) - Added the customers order number to succes page.
141
- ([@Jessevdpoel](https://github.com/Jessevdpoel))
345
+ - [#2075](https://github.com/graphcommerce-org/graphcommerce/pull/2075) [`34dee45`](https://github.com/graphcommerce-org/graphcommerce/commit/34dee456ef686174b62e604911a0ba84cbd3d002) - Added the customers order number to succes page. ([@Jessevdpoel](https://github.com/Jessevdpoel))
142
346
 
143
- - [#2018](https://github.com/graphcommerce-org/graphcommerce/pull/2018) [`750aa6a`](https://github.com/graphcommerce-org/graphcommerce/commit/750aa6a72710869d54244467253212e551d335e0) - Changed the layout of the succes page. We are using ActionCards right now to match the design of the cart.
144
- ([@Jessevdpoel](https://github.com/Jessevdpoel))
347
+ - [#2018](https://github.com/graphcommerce-org/graphcommerce/pull/2018) [`750aa6a`](https://github.com/graphcommerce-org/graphcommerce/commit/750aa6a72710869d54244467253212e551d335e0) - Changed the layout of the succes page. We are using ActionCards right now to match the design of the cart. ([@Jessevdpoel](https://github.com/Jessevdpoel))
145
348
 
146
349
  ### Patch Changes
147
350
 
148
- - [#2184](https://github.com/graphcommerce-org/graphcommerce/pull/2184) [`28b7e6e`](https://github.com/graphcommerce-org/graphcommerce/commit/28b7e6ef3e3f698751c6e82431fd14fb35463dd6) - When a customer would return from a payment gateway and it would erroneously query the cart GraphCommerce would immediately create a new empty cart while it shouldn't.
149
- ([@paales](https://github.com/paales))
351
+ - [#2184](https://github.com/graphcommerce-org/graphcommerce/pull/2184) [`28b7e6e`](https://github.com/graphcommerce-org/graphcommerce/commit/28b7e6ef3e3f698751c6e82431fd14fb35463dd6) - When a customer would return from a payment gateway and it would erroneously query the cart GraphCommerce would immediately create a new empty cart while it shouldn't. ([@paales](https://github.com/paales))
150
352
 
151
- - [#1999](https://github.com/graphcommerce-org/graphcommerce/pull/1999) [`6d7ed0a`](https://github.com/graphcommerce-org/graphcommerce/commit/6d7ed0a2a3d9b3c6193f86bce6889ff24adf3e83) - After signing in the `<CartFab/>` would not always properly reflect if there are items in the customers cart.
152
- ([@paales](https://github.com/paales))
353
+ - [#1999](https://github.com/graphcommerce-org/graphcommerce/pull/1999) [`6d7ed0a`](https://github.com/graphcommerce-org/graphcommerce/commit/6d7ed0a2a3d9b3c6193f86bce6889ff24adf3e83) - After signing in the `<CartFab/>` would not always properly reflect if there are items in the customers cart. ([@paales](https://github.com/paales))
153
354
 
154
- - [#2089](https://github.com/graphcommerce-org/graphcommerce/pull/2089) [`4b6bbf0`](https://github.com/graphcommerce-org/graphcommerce/commit/4b6bbf06572c71e266cc2407e4533833712898e2) - The `<CartFab/>` wouldn't reflect that there are items in the cart when a customer refreshes the page after adding a product to the cart, without viewing the cart.
155
- ([@carlocarels90](https://github.com/carlocarels90))
355
+ - [#2089](https://github.com/graphcommerce-org/graphcommerce/pull/2089) [`4b6bbf0`](https://github.com/graphcommerce-org/graphcommerce/commit/4b6bbf06572c71e266cc2407e4533833712898e2) - The `<CartFab/>` wouldn't reflect that there are items in the cart when a customer refreshes the page after adding a product to the cart, without viewing the cart. ([@carlocarels90](https://github.com/carlocarels90))
156
356
 
157
- - [#2170](https://github.com/graphcommerce-org/graphcommerce/pull/2170) [`f3e906f`](https://github.com/graphcommerce-org/graphcommerce/commit/f3e906f7e374ce22d36af29c0f3c8153e18300e6) - Solved an issue where the inactive cart would set as the current cart when the customer had signed in, checked out their cart, session expired and tried to log in again.
158
- ([@FrankHarland](https://github.com/FrankHarland))
357
+ - [#2170](https://github.com/graphcommerce-org/graphcommerce/pull/2170) [`f3e906f`](https://github.com/graphcommerce-org/graphcommerce/commit/f3e906f7e374ce22d36af29c0f3c8153e18300e6) - Solved an issue where the inactive cart would set as the current cart when the customer had signed in, checked out their cart, session expired and tried to log in again. ([@FrankHarland](https://github.com/FrankHarland))
159
358
 
160
- - [#2107](https://github.com/graphcommerce-org/graphcommerce/pull/2107) [`2f51504`](https://github.com/graphcommerce-org/graphcommerce/commit/2f5150456eabcce410ad8a0f1cbebeedabb6564c) - Remember email adress when going from checkout to signin/up form
161
- ([@FrankHarland](https://github.com/FrankHarland))
359
+ - [#2107](https://github.com/graphcommerce-org/graphcommerce/pull/2107) [`2f51504`](https://github.com/graphcommerce-org/graphcommerce/commit/2f5150456eabcce410ad8a0f1cbebeedabb6564c) - Remember email adress when going from checkout to signin/up form ([@FrankHarland](https://github.com/FrankHarland))
162
360
 
163
- - [#1999](https://github.com/graphcommerce-org/graphcommerce/pull/1999) [`ab834fb`](https://github.com/graphcommerce-org/graphcommerce/commit/ab834fbfe057fb507c371a6d22af282cc1b195d4) - Added a new 'Session expired' dialog that is shown when a GraphQL query or mutation returns a `graphql-authorization` error. This error is returned when the user's session has expired. The dialog allows the user to sign in again and then the query or mutation is re-executed.
164
- ([@paales](https://github.com/paales))
361
+ - [#1999](https://github.com/graphcommerce-org/graphcommerce/pull/1999) [`ab834fb`](https://github.com/graphcommerce-org/graphcommerce/commit/ab834fbfe057fb507c371a6d22af282cc1b195d4) - Added a new 'Session expired' dialog that is shown when a GraphQL query or mutation returns a `graphql-authorization` error. This error is returned when the user's session has expired. The dialog allows the user to sign in again and then the query or mutation is re-executed. ([@paales](https://github.com/paales))
165
362
 
166
363
  ## 8.0.0-canary.100
167
364
 
168
365
  ### Patch Changes
169
366
 
170
- - [#2184](https://github.com/graphcommerce-org/graphcommerce/pull/2184) [`28b7e6e`](https://github.com/graphcommerce-org/graphcommerce/commit/28b7e6ef3e3f698751c6e82431fd14fb35463dd6) - When a customer would return from a payment gateway and it would erroneously query the cart GraphCommerce would immediately create a new empty cart while it shouldn't.
171
- ([@paales](https://github.com/paales))
367
+ - [#2184](https://github.com/graphcommerce-org/graphcommerce/pull/2184) [`28b7e6e`](https://github.com/graphcommerce-org/graphcommerce/commit/28b7e6ef3e3f698751c6e82431fd14fb35463dd6) - When a customer would return from a payment gateway and it would erroneously query the cart GraphCommerce would immediately create a new empty cart while it shouldn't. ([@paales](https://github.com/paales))
172
368
 
173
369
  ## 8.0.0-canary.99
174
370
 
@@ -192,8 +388,7 @@
192
388
 
193
389
  ### Patch Changes
194
390
 
195
- - [#2170](https://github.com/graphcommerce-org/graphcommerce/pull/2170) [`f3e906f`](https://github.com/graphcommerce-org/graphcommerce/commit/f3e906f7e374ce22d36af29c0f3c8153e18300e6) - fix(GCOM-1317): fix bug where inactive cached cart could be set as currentCartId
196
- ([@FrankHarland](https://github.com/FrankHarland))
391
+ - [#2170](https://github.com/graphcommerce-org/graphcommerce/pull/2170) [`f3e906f`](https://github.com/graphcommerce-org/graphcommerce/commit/f3e906f7e374ce22d36af29c0f3c8153e18300e6) - fix(GCOM-1317): fix bug where inactive cached cart could be set as currentCartId ([@FrankHarland](https://github.com/FrankHarland))
197
392
 
198
393
  ## 8.0.0-canary.89
199
394
 
@@ -241,11 +436,9 @@
241
436
 
242
437
  ### Patch Changes
243
438
 
244
- - [#1999](https://github.com/graphcommerce-org/graphcommerce/pull/1999) [`6d7ed0a`](https://github.com/graphcommerce-org/graphcommerce/commit/6d7ed0a2a3d9b3c6193f86bce6889ff24adf3e83) - When signing in the cartFab would not always properly reflect the current items in the cart
245
- ([@paales](https://github.com/paales))
439
+ - [#1999](https://github.com/graphcommerce-org/graphcommerce/pull/1999) [`6d7ed0a`](https://github.com/graphcommerce-org/graphcommerce/commit/6d7ed0a2a3d9b3c6193f86bce6889ff24adf3e83) - When signing in the cartFab would not always properly reflect the current items in the cart ([@paales](https://github.com/paales))
246
440
 
247
- - [#1999](https://github.com/graphcommerce-org/graphcommerce/pull/1999) [`ab834fb`](https://github.com/graphcommerce-org/graphcommerce/commit/ab834fbfe057fb507c371a6d22af282cc1b195d4) - Added user session reevaluation after unathenticated call. Queries will be paused untill user has signed in again
248
- ([@paales](https://github.com/paales))
441
+ - [#1999](https://github.com/graphcommerce-org/graphcommerce/pull/1999) [`ab834fb`](https://github.com/graphcommerce-org/graphcommerce/commit/ab834fbfe057fb507c371a6d22af282cc1b195d4) - Added user session reevaluation after unathenticated call. Queries will be paused untill user has signed in again ([@paales](https://github.com/paales))
249
442
 
250
443
  ## 7.1.0-canary.67
251
444
 
@@ -1689,31 +1882,31 @@
1689
1882
  All occurences of `<Trans>` and `t` need to be replaced:
1690
1883
 
1691
1884
  ```tsx
1692
- import { Trans, t } from "@lingui/macro";
1885
+ import { Trans, t } from '@lingui/macro'
1693
1886
 
1694
1887
  function MyComponent() {
1695
- const foo = "bar";
1888
+ const foo = 'bar'
1696
1889
  return (
1697
1890
  <div aria-label={t`Account ${foo}`}>
1698
1891
  <Trans>My Translation {foo}</Trans>
1699
1892
  </div>
1700
- );
1893
+ )
1701
1894
  }
1702
1895
  ```
1703
1896
 
1704
1897
  Needs to be replaced with:
1705
1898
 
1706
1899
  ```tsx
1707
- import { Trans } from "@lingui/react";
1708
- import { i18n } from "@lingui/core";
1900
+ import { Trans } from '@lingui/react'
1901
+ import { i18n } from '@lingui/core'
1709
1902
 
1710
1903
  function MyComponent() {
1711
- const foo = "bar";
1904
+ const foo = 'bar'
1712
1905
  return (
1713
1906
  <div aria-label={i18n._(/* i18n */ `Account {foo}`, { foo })}>
1714
- <Trans key="My Translation {foo}" values={{ foo }}></Trans>
1907
+ <Trans key='My Translation {foo}' values={{ foo }}></Trans>
1715
1908
  </div>
1716
- );
1909
+ )
1717
1910
  }
1718
1911
  ```
1719
1912
 
package/Config.graphqls CHANGED
@@ -1,3 +1,20 @@
1
+ enum CartPermissions {
2
+ ENABLED
3
+ CUSTOMER_ONLY
4
+ DISABLED
5
+ }
6
+
7
+ extend input GraphCommercePermissions {
8
+ """
9
+ Changes the availability of the add to cart buttons and the cart page to either customer only or completely disables it.
10
+ """
11
+ cart: CartPermissions
12
+ """
13
+ Changes the availability of the checkout to either customer only or completely disables it.
14
+ """
15
+ checkout: CartPermissions
16
+ }
17
+
1
18
  extend input GraphCommerceStorefrontConfig {
2
19
  """
3
20
  Due to a limitation of the GraphQL API it is not possible to determine if a cart should be displayed including or excluding tax.
@@ -1,55 +1,10 @@
1
- import { useQuery } from '@graphcommerce/graphql'
2
1
  import {
3
2
  ApolloCustomerErrorAlert,
4
3
  ApolloCustomerErrorAlertProps,
5
- CustomerDocument,
6
4
  } from '@graphcommerce/magento-customer'
7
- import { graphqlErrorByCategory } from '@graphcommerce/magento-graphql'
8
- import { i18n } from '@lingui/core'
9
- import { Trans } from '@lingui/react'
10
- import { Button } from '@mui/material'
11
- import { useClearCurrentCartId } from '../../hooks'
12
5
 
13
6
  export type ApolloCartErrorAlertProps = ApolloCustomerErrorAlertProps
14
7
 
15
8
  export function ApolloCartErrorAlert(props: ApolloCartErrorAlertProps) {
16
- const { error, graphqlErrorAlertProps } = props
17
-
18
- const email = useQuery(CustomerDocument, { fetchPolicy: 'cache-only' }).data?.customer?.email
19
-
20
- const [newError, unauthorized] = graphqlErrorByCategory({
21
- category: 'graphql-authorization',
22
- error,
23
- mask: email
24
- ? i18n._(
25
- /* i18n */ 'This cart is assigned to {email}. Please sign in to continue shopping.',
26
- { email },
27
- )
28
- : undefined,
29
- extract: false,
30
- })
31
-
32
- const clear = useClearCurrentCartId()
33
-
34
- return (
35
- <ApolloCustomerErrorAlert
36
- {...props}
37
- error={newError}
38
- graphqlErrorAlertProps={{
39
- action: unauthorized ? (
40
- <>
41
- {graphqlErrorAlertProps?.action}
42
- <Button onClick={clear} color='error' size='small'>
43
- <Trans id='Sign out' />
44
- </Button>
45
- <Button href='/account/signin' color='error' size='small'>
46
- <Trans id='Sign in' />
47
- </Button>
48
- </>
49
- ) : (
50
- graphqlErrorAlertProps?.action
51
- ),
52
- }}
53
- />
54
- )
9
+ return <ApolloCustomerErrorAlert {...props} />
55
10
  }
@@ -4,6 +4,7 @@ fragment CartAddress on CartAddressInterface {
4
4
  lastname
5
5
  city
6
6
  company
7
+ vat_id
7
8
  country {
8
9
  code
9
10
  label
@@ -8,7 +8,7 @@ import {
8
8
  UseFormComposeOptions,
9
9
  } from '@graphcommerce/react-hook-form'
10
10
  import { i18n } from '@lingui/core'
11
- import { Box, Link, SxProps, Theme } from '@mui/material'
11
+ import { Box, Link, SxProps, Theme, Typography } from '@mui/material'
12
12
  import React from 'react'
13
13
  import { CartAgreementsDocument } from './CartAgreements.gql'
14
14
 
@@ -18,26 +18,34 @@ const componentName = 'CartAgreementsForm' as const
18
18
  const parts = ['form', 'formInner', 'formControlRoot', 'manualCheck'] as const
19
19
  const { classes } = extendableComponent(componentName, parts)
20
20
 
21
+ /**
22
+ * Checks if a string contains an anchor tag (<a> ... </a>).
23
+ * @param {string} str - The string to check.
24
+ * @returns {boolean} - True if the string contains an anchor tag, otherwise false.
25
+ */
26
+ const containsAnchorTag = (str: string): boolean => {
27
+ const anchorTagRegex = /<a\s+[^>]*>(.*?)<\/a>/i
28
+ return anchorTagRegex.test(str)
29
+ }
30
+
21
31
  export function CartAgreementsForm(props: CartAgreementsFormProps) {
22
32
  const { step, sx = [] } = props
23
33
  const { data } = useQuery(CartAgreementsDocument)
24
34
 
25
35
  // sort conditions so checkboxes will be placed first
26
36
  const sortedAgreements = data?.checkoutAgreements
27
- ? [...data.checkoutAgreements].sort((a, b) =>
28
- // eslint-disable-next-line no-nested-ternary
29
- a?.mode === 'MANUAL' ? -1 : b?.mode === 'MANUAL' ? 1 : 0,
30
- )
37
+ ? [...data.checkoutAgreements]?.sort((a, b) => {
38
+ if (a?.mode === 'MANUAL') return -1
39
+ if (b?.mode === 'MANUAL') return 1
40
+ return 0
41
+ })
31
42
  : []
32
43
 
33
44
  const form = useForm()
34
45
 
35
46
  const { handleSubmit, control } = form
36
47
 
37
- const submit = handleSubmit((values) => {
38
- // eslint-disable-next-line no-console
39
- console.log(values)
40
- })
48
+ const submit = handleSubmit(() => {})
41
49
 
42
50
  useFormCompose({ form, step, submit, key: 'PaymentAgreementsForm' })
43
51
 
@@ -48,7 +56,6 @@ export function CartAgreementsForm(props: CartAgreementsFormProps) {
48
56
  className={classes.form}
49
57
  sx={[(theme) => ({ pt: theme.spacings.md }), ...(Array.isArray(sx) ? sx : [sx])]}
50
58
  >
51
- <FormPersist form={form} name='PaymentAgreementsForm' />
52
59
  <form noValidate onSubmit={submit} name='cartAgreements'>
53
60
  <Box className={classes.formInner} sx={{ typography: 'body1', display: 'inline-block' }}>
54
61
  {data?.checkoutAgreements &&
@@ -56,6 +63,45 @@ export function CartAgreementsForm(props: CartAgreementsFormProps) {
56
63
  if (!agreement) return null
57
64
  const href = `/checkout/terms/${agreement.name?.toLowerCase().replace(/\s+/g, '-')}`
58
65
  const agreementTextParts = agreement.checkbox_text.split(agreement.name)
66
+ // check if the agreement text contains an anchor tag
67
+ const containsLink = containsAnchorTag(agreement.checkbox_text)
68
+ let labelContent: React.ReactNode
69
+
70
+ if (containsLink) {
71
+ labelContent = (
72
+ <Typography
73
+ dangerouslySetInnerHTML={{ __html: agreement.checkbox_text }}
74
+ sx={{
75
+ '& a': {
76
+ color: 'secondary.main',
77
+ textDecoration: 'none',
78
+ '&:hover, &:focus, &:active': {
79
+ textDecoration: 'underline',
80
+ },
81
+ },
82
+ }}
83
+ />
84
+ )
85
+ } else if (
86
+ agreement.mode === 'MANUAL' &&
87
+ agreement.checkbox_text.includes(agreement.name)
88
+ ) {
89
+ labelContent = (
90
+ <>
91
+ {agreementTextParts[0]}
92
+ <Link href={href} color='secondary' underline='hover'>
93
+ {agreement.name}
94
+ </Link>
95
+ {agreementTextParts[1]}
96
+ </>
97
+ )
98
+ } else {
99
+ labelContent = (
100
+ <Link href={href} color='secondary' underline='hover'>
101
+ {agreement.checkbox_text}
102
+ </Link>
103
+ )
104
+ }
59
105
 
60
106
  return (
61
107
  <React.Fragment key={agreement.agreement_id}>
@@ -63,36 +109,16 @@ export function CartAgreementsForm(props: CartAgreementsFormProps) {
63
109
  <CheckboxElement
64
110
  control={control}
65
111
  color='secondary'
66
- formControl={{
67
- sx: {
68
- display: 'block',
69
- },
70
- }}
112
+ formControl={{ sx: { display: 'block' } }}
71
113
  name={`agreement${agreement.agreement_id}`}
72
114
  rules={{
73
115
  required: i18n._(/* i18n */ 'You have to agree in order to proceed'),
74
116
  }}
75
- label={
76
- agreement.checkbox_text.includes(agreement.name) ? (
77
- <>
78
- {agreementTextParts[0]}
79
- <Link href={href} color='secondary' underline='hover'>
80
- {agreement.name}
81
- </Link>
82
- {agreementTextParts[1]}
83
- </>
84
- ) : (
85
- <Link href={href} color='secondary' underline='hover'>
86
- {agreement.checkbox_text}
87
- </Link>
88
- )
89
- }
117
+ label={labelContent}
90
118
  />
91
119
  ) : (
92
120
  <Box className={classes.manualCheck} sx={{ padding: `9px 0` }}>
93
- <Link href={href} color='secondary' underline='hover'>
94
- {agreement.checkbox_text}
95
- </Link>
121
+ {labelContent}
96
122
  </Box>
97
123
  )}
98
124
  </React.Fragment>
@@ -100,6 +126,7 @@ export function CartAgreementsForm(props: CartAgreementsFormProps) {
100
126
  })}
101
127
  </Box>
102
128
  </form>
129
+ <FormPersist form={form} name='PaymentAgreementsForm' />
103
130
  </FormDiv>
104
131
  )
105
132
  }