@graphcommerce/magento-cart 8.1.0-canary.9 → 9.0.0-canary.101

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 (32) 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 +8 -2
  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/cartLink.ts +127 -0
  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
  32. package/link/createCartErrorLink.ts +0 -71
@@ -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,13 +1,228 @@
1
1
  # Change Log
2
2
 
3
+ ## 9.0.0-canary.101
4
+
5
+ ## 9.0.0-canary.100
6
+
7
+ ## 9.0.0-canary.99
8
+
9
+ ## 9.0.0-canary.98
10
+
11
+ ## 9.0.0-canary.97
12
+
13
+ ## 9.0.0-canary.96
14
+
15
+ ## 9.0.0-canary.95
16
+
17
+ ## 9.0.0-canary.94
18
+
19
+ ## 9.0.0-canary.93
20
+
21
+ ## 9.0.0-canary.92
22
+
23
+ ## 9.0.0-canary.91
24
+
25
+ ## 9.0.0-canary.90
26
+
27
+ ## 9.0.0-canary.89
28
+
29
+ ## 9.0.0-canary.88
30
+
31
+ ## 9.0.0-canary.87
32
+
33
+ ## 9.0.0-canary.86
34
+
35
+ ## 9.0.0-canary.85
36
+
37
+ ## 9.0.0-canary.84
38
+
39
+ ## 9.0.0-canary.83
40
+
41
+ ## 9.0.0-canary.82
42
+
43
+ ### Minor Changes
44
+
45
+ - [#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))
46
+
47
+ ## 9.0.0-canary.81
48
+
49
+ ## 9.0.0-canary.80
50
+
51
+ ## 9.0.0-canary.79
52
+
53
+ ## 9.0.0-canary.78
54
+
55
+ ## 9.0.0-canary.77
56
+
57
+ ## 9.0.0-canary.76
58
+
59
+ ## 9.0.0-canary.75
60
+
61
+ ## 9.0.0-canary.74
62
+
63
+ ## 9.0.0-canary.73
64
+
65
+ ## 9.0.0-canary.72
66
+
67
+ ## 9.0.0-canary.71
68
+
69
+ ## 9.0.0-canary.70
70
+
71
+ ## 9.0.0-canary.69
72
+
73
+ ### Patch Changes
74
+
75
+ - [#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))
76
+
77
+ ## 9.0.0-canary.68
78
+
79
+ ## 9.0.0-canary.67
80
+
81
+ ## 9.0.0-canary.66
82
+
83
+ ## 9.0.0-canary.65
84
+
85
+ ## 9.0.0-canary.64
86
+
87
+ ## 9.0.0-canary.63
88
+
89
+ ## 9.0.0-canary.62
90
+
91
+ ## 9.0.0-canary.61
92
+
93
+ ## 9.0.0-canary.60
94
+
95
+ ## 9.0.0-canary.59
96
+
97
+ ## 9.0.0-canary.58
98
+
99
+ ## 9.0.0-canary.57
100
+
101
+ ## 9.0.0-canary.56
102
+
103
+ ## 9.0.0-canary.55
104
+
105
+ ## 9.0.0-canary.54
106
+
107
+ ## 8.1.0-canary.53
108
+
109
+ ## 8.1.0-canary.52
110
+
111
+ ## 8.1.0-canary.51
112
+
113
+ ## 8.1.0-canary.50
114
+
115
+ ## 8.1.0-canary.49
116
+
117
+ ## 8.1.0-canary.48
118
+
119
+ ## 8.1.0-canary.47
120
+
121
+ ## 8.1.0-canary.46
122
+
123
+ ## 8.1.0-canary.45
124
+
125
+ ### Patch Changes
126
+
127
+ - [#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))
128
+
129
+ ## 8.1.0-canary.44
130
+
131
+ ## 8.1.0-canary.43
132
+
133
+ ## 8.1.0-canary.42
134
+
135
+ ## 8.1.0-canary.41
136
+
137
+ ## 8.1.0-canary.40
138
+
139
+ ## 8.1.0-canary.39
140
+
141
+ ## 8.1.0-canary.38
142
+
143
+ ### Minor Changes
144
+
145
+ - [#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))
146
+
147
+ ### Patch Changes
148
+
149
+ - [#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))
150
+
151
+ ## 8.1.0-canary.37
152
+
153
+ ## 8.1.0-canary.36
154
+
155
+ ## 8.1.0-canary.35
156
+
157
+ ### Patch Changes
158
+
159
+ - [#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))
160
+
161
+ ## 8.1.0-canary.34
162
+
163
+ ### Minor Changes
164
+
165
+ - [#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))
166
+
167
+ ## 8.1.0-canary.33
168
+
169
+ ## 8.1.0-canary.32
170
+
171
+ ## 8.1.0-canary.31
172
+
173
+ ## 8.1.0-canary.30
174
+
175
+ ## 8.1.0-canary.29
176
+
177
+ ## 8.1.0-canary.28
178
+
179
+ ## 8.1.0-canary.27
180
+
181
+ ## 8.1.0-canary.26
182
+
183
+ ## 8.1.0-canary.25
184
+
185
+ ### Patch Changes
186
+
187
+ - [#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))
188
+
189
+ ## 8.1.0-canary.24
190
+
191
+ ## 8.1.0-canary.23
192
+
193
+ ## 8.1.0-canary.22
194
+
195
+ ## 8.1.0-canary.21
196
+
197
+ ## 8.1.0-canary.20
198
+
199
+ ## 8.1.0-canary.19
200
+
201
+ ## 8.1.0-canary.18
202
+
203
+ ## 8.1.0-canary.17
204
+
205
+ ## 8.1.0-canary.16
206
+
207
+ ## 8.1.0-canary.15
208
+
209
+ ## 8.1.0-canary.14
210
+
211
+ ## 8.1.0-canary.13
212
+
213
+ ## 8.1.0-canary.12
214
+
215
+ ## 8.1.0-canary.11
216
+
217
+ ## 8.1.0-canary.10
218
+
3
219
  ## 8.1.0-canary.9
4
220
 
5
221
  ## 8.1.0-canary.8
6
222
 
7
223
  ### Patch Changes
8
224
 
9
- - [#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
10
- ([@paales](https://github.com/paales))
225
+ - [#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))
11
226
 
12
227
  ## 8.1.0-canary.7
13
228
 
@@ -23,11 +238,9 @@
23
238
 
24
239
  ### Patch Changes
25
240
 
26
- - [#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
27
- ([@FrankHarland](https://github.com/FrankHarland))
241
+ - [#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))
28
242
 
29
- - [#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.
30
- ([@FrankHarland](https://github.com/FrankHarland))
243
+ - [#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))
31
244
 
32
245
  ## 8.0.6-canary.1
33
246
 
@@ -61,8 +274,7 @@
61
274
 
62
275
  ### Patch Changes
63
276
 
64
- - [#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.
65
- ([@paales](https://github.com/paales))
277
+ - [#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))
66
278
 
67
279
  ## 8.0.4-canary.1
68
280
 
@@ -70,21 +282,17 @@
70
282
 
71
283
  ### Patch Changes
72
284
 
73
- - [#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.
74
- ([@paales](https://github.com/paales))
285
+ - [#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))
75
286
 
76
287
  ## 8.0.3
77
288
 
78
289
  ### Patch Changes
79
290
 
80
- - [#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.
81
- ([@paales](https://github.com/paales))
291
+ - [#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))
82
292
 
83
- - [#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.
84
- ([@paales](https://github.com/paales))
293
+ - [#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))
85
294
 
86
- - [#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
87
- ([@paales](https://github.com/paales))
295
+ - [#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))
88
296
 
89
297
  ## 8.0.3-canary.6
90
298
 
@@ -98,18 +306,15 @@
98
306
 
99
307
  ### Patch Changes
100
308
 
101
- - [#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.
102
- ([@paales](https://github.com/paales))
309
+ - [#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))
103
310
 
104
- - [#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.
105
- ([@paales](https://github.com/paales))
311
+ - [#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))
106
312
 
107
313
  ## 8.0.3-canary.1
108
314
 
109
315
  ### Patch Changes
110
316
 
111
- - [#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
112
- ([@paales](https://github.com/paales))
317
+ - [#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))
113
318
 
114
319
  ## 8.0.3-canary.0
115
320
 
@@ -139,38 +344,29 @@
139
344
 
140
345
  ### Minor Changes
141
346
 
142
- - [#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.
143
- ([@Jessevdpoel](https://github.com/Jessevdpoel))
347
+ - [#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))
144
348
 
145
- - [#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.
146
- ([@Jessevdpoel](https://github.com/Jessevdpoel))
349
+ - [#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))
147
350
 
148
351
  ### Patch Changes
149
352
 
150
- - [#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.
151
- ([@paales](https://github.com/paales))
353
+ - [#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))
152
354
 
153
- - [#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.
154
- ([@paales](https://github.com/paales))
355
+ - [#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))
155
356
 
156
- - [#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.
157
- ([@carlocarels90](https://github.com/carlocarels90))
357
+ - [#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))
158
358
 
159
- - [#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.
160
- ([@FrankHarland](https://github.com/FrankHarland))
359
+ - [#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))
161
360
 
162
- - [#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
163
- ([@FrankHarland](https://github.com/FrankHarland))
361
+ - [#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))
164
362
 
165
- - [#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.
166
- ([@paales](https://github.com/paales))
363
+ - [#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))
167
364
 
168
365
  ## 8.0.0-canary.100
169
366
 
170
367
  ### Patch Changes
171
368
 
172
- - [#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.
173
- ([@paales](https://github.com/paales))
369
+ - [#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))
174
370
 
175
371
  ## 8.0.0-canary.99
176
372
 
@@ -194,8 +390,7 @@
194
390
 
195
391
  ### Patch Changes
196
392
 
197
- - [#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
198
- ([@FrankHarland](https://github.com/FrankHarland))
393
+ - [#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))
199
394
 
200
395
  ## 8.0.0-canary.89
201
396
 
@@ -243,11 +438,9 @@
243
438
 
244
439
  ### Patch Changes
245
440
 
246
- - [#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
247
- ([@paales](https://github.com/paales))
441
+ - [#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))
248
442
 
249
- - [#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
250
- ([@paales](https://github.com/paales))
443
+ - [#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))
251
444
 
252
445
  ## 7.1.0-canary.67
253
446
 
@@ -1691,31 +1884,31 @@
1691
1884
  All occurences of `<Trans>` and `t` need to be replaced:
1692
1885
 
1693
1886
  ```tsx
1694
- import { Trans, t } from "@lingui/macro";
1887
+ import { Trans, t } from '@lingui/macro'
1695
1888
 
1696
1889
  function MyComponent() {
1697
- const foo = "bar";
1890
+ const foo = 'bar'
1698
1891
  return (
1699
1892
  <div aria-label={t`Account ${foo}`}>
1700
1893
  <Trans>My Translation {foo}</Trans>
1701
1894
  </div>
1702
- );
1895
+ )
1703
1896
  }
1704
1897
  ```
1705
1898
 
1706
1899
  Needs to be replaced with:
1707
1900
 
1708
1901
  ```tsx
1709
- import { Trans } from "@lingui/react";
1710
- import { i18n } from "@lingui/core";
1902
+ import { Trans } from '@lingui/react'
1903
+ import { i18n } from '@lingui/core'
1711
1904
 
1712
1905
  function MyComponent() {
1713
- const foo = "bar";
1906
+ const foo = 'bar'
1714
1907
  return (
1715
1908
  <div aria-label={i18n._(/* i18n */ `Account {foo}`, { foo })}>
1716
- <Trans key="My Translation {foo}" values={{ foo }}></Trans>
1909
+ <Trans key='My Translation {foo}' values={{ foo }}></Trans>
1717
1910
  </div>
1718
- );
1911
+ )
1719
1912
  }
1720
1913
  ```
1721
1914
 
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
  }