@salesforce/retail-react-app 2.3.1 → 2.4.0-dev.1

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/CHANGELOG.md +15 -0
  2. package/app/components/_app-config/index.jsx +12 -0
  3. package/app/components/confirmation-modal/index.jsx +11 -4
  4. package/app/components/item-variant/item-image.jsx +18 -0
  5. package/app/components/product-item/index.test.js +1 -1
  6. package/app/components/promo-code/index.jsx +25 -28
  7. package/app/components/unavailable-product-confirmation-modal/index.jsx +72 -0
  8. package/app/components/unavailable-product-confirmation-modal/index.test.js +362 -0
  9. package/app/constants.js +18 -0
  10. package/app/hooks/einstein-mock-data.js +157 -0
  11. package/app/hooks/use-einstein.js +3 -4
  12. package/app/hooks/use-einstein.test.js +19 -1
  13. package/app/pages/account/index.jsx +1 -1
  14. package/app/pages/account/order-detail.jsx +16 -14
  15. package/app/pages/account/profile.jsx +21 -30
  16. package/app/pages/account/wishlist/index.jsx +25 -1
  17. package/app/pages/cart/index.jsx +24 -6
  18. package/app/pages/checkout/index.jsx +55 -6
  19. package/app/pages/checkout/index.test.js +23 -7
  20. package/app/pages/checkout/partials/payment.jsx +2 -2
  21. package/app/pages/checkout/partials/shipping-options.jsx +1 -1
  22. package/app/pages/product-detail/index.jsx +1 -1
  23. package/app/pages/product-list/index.jsx +5 -2
  24. package/app/ssr.js +18 -1
  25. package/app/static/translations/compiled/en-GB.json +24 -0
  26. package/app/static/translations/compiled/en-US.json +24 -0
  27. package/app/static/translations/compiled/en-XA.json +56 -0
  28. package/app/utils/test-utils.js +1 -0
  29. package/app/utils/url.js +1 -4
  30. package/package.json +6 -6
  31. package/translations/en-GB.json +13 -0
  32. package/translations/en-US.json +13 -0
@@ -65,7 +65,19 @@ beforeEach(() => {
65
65
  global.server.use(
66
66
  // mock product details
67
67
  rest.get('*/products', (req, res, ctx) => {
68
- return res(ctx.json({data: [{id: '701642811398M'}]}))
68
+ return res(
69
+ ctx.json({
70
+ data: [
71
+ {
72
+ id: '701643070725M',
73
+ currency: 'GBP',
74
+ name: 'Long Sleeve Crew Neck',
75
+ pricePerUnit: 19.18,
76
+ price: 19.18
77
+ }
78
+ ]
79
+ })
80
+ )
69
81
  }),
70
82
  // mock the available shipping methods
71
83
  rest.get('*/shipments/me/shipping-methods', (req, res, ctx) => {
@@ -162,11 +174,13 @@ beforeEach(() => {
162
174
 
163
175
  // mock place order
164
176
  rest.post('*/orders', (req, res, ctx) => {
165
- currentBasket = {
177
+ const response = {
178
+ ...currentBasket,
166
179
  ...scapiOrderResponse,
167
- customerInfo: {...scapiOrderResponse.customerInfo, email: 'customer@test.com'}
180
+ customerInfo: {...scapiOrderResponse.customerInfo, email: 'customer@test.com'},
181
+ status: 'created'
168
182
  }
169
- return res(ctx.json(currentBasket))
183
+ return res(ctx.json(response))
170
184
  }),
171
185
 
172
186
  rest.get('*/baskets', (req, res, ctx) => {
@@ -272,11 +286,13 @@ test('Can proceed through checkout steps as guest', async () => {
272
286
 
273
287
  // mock place order
274
288
  rest.post('*/orders', (req, res, ctx) => {
275
- currentBasket = {
289
+ const response = {
290
+ ...currentBasket,
276
291
  ...scapiOrderResponse,
277
- customerInfo: {...scapiOrderResponse.customerInfo, email: 'test@test.com'}
292
+ customerInfo: {...scapiOrderResponse.customerInfo, email: 'customer@test.com'},
293
+ status: 'created'
278
294
  }
279
- return res(ctx.json(currentBasket))
295
+ return res(ctx.json(response))
280
296
  }),
281
297
 
282
298
  rest.get('*/baskets', (req, res, ctx) => {
@@ -109,9 +109,9 @@ const Payment = () => {
109
109
  // Using destructuring to remove properties from the object...
110
110
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
111
111
  const {addressId, creationDate, lastModified, preferred, ...address} = billingAddress
112
- return updateBillingAddressForBasket({
112
+ return await updateBillingAddressForBasket({
113
113
  body: address,
114
- parameters: {basketId: basket.basketId, shipmentId: 'me'}
114
+ parameters: {basketId: basket.basketId}
115
115
  })
116
116
  }
117
117
  const onPaymentRemoval = async () => {
@@ -45,7 +45,7 @@ export default function ShippingOptions() {
45
45
  }
46
46
  },
47
47
  {
48
- enabled: Boolean(basket?.basketId) && step === STEPS.ShippingOptions
48
+ enabled: Boolean(basket?.basketId) && step === STEPS.SHIPPING_OPTIONS
49
49
  }
50
50
  )
51
51
 
@@ -99,7 +99,7 @@ const ProductDetail = () => {
99
99
  } = useCategory({
100
100
  parameters: {
101
101
  id: product?.primaryCategoryId,
102
- level: 1
102
+ levels: 1
103
103
  }
104
104
  })
105
105
 
@@ -137,6 +137,9 @@ const ProductList = (props) => {
137
137
  )
138
138
 
139
139
  /**************** Query Actions ****************/
140
+ // _refine is an invalid param for useProductSearch, we don't want to pass it to API call
141
+ const {_refine, ...restOfParams} = searchParams
142
+
140
143
  const {
141
144
  isLoading,
142
145
  isRefetching,
@@ -144,8 +147,8 @@ const ProductList = (props) => {
144
147
  } = useProductSearch(
145
148
  {
146
149
  parameters: {
147
- ...searchParams,
148
- refine: searchParams._refine
150
+ ...restOfParams,
151
+ refine: _refine
149
152
  }
150
153
  },
151
154
  {
package/app/ssr.js CHANGED
@@ -5,6 +5,15 @@
5
5
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
6
  */
7
7
 
8
+ /*
9
+ * Developer note! When updating this file, make sure to also update the
10
+ * ssr.js template files in pwa-kit-create-app.
11
+ *
12
+ * In the pwa-kit-create-app, the templates are found under:
13
+ * - assets/bootstrap/js/overrides/app/ssr.js.hbs
14
+ * - assets/templates/@salesforce/retail-react-app/app/ssr.js.hbs
15
+ */
16
+
8
17
  'use strict'
9
18
 
10
19
  import path from 'path'
@@ -29,7 +38,14 @@ const options = {
29
38
  // The protocol on which the development Express app listens.
30
39
  // Note that http://localhost is treated as a secure context for development,
31
40
  // except by Safari.
32
- protocol: 'http'
41
+ protocol: 'http',
42
+
43
+ // Option for whether to set up a special endpoint for handling
44
+ // private SLAS clients
45
+ // Set this to false if using a SLAS public client
46
+ // When setting this to true, make sure to also set the PWA_KIT_SLAS_CLIENT_SECRET
47
+ // environment variable as this endpoint will return HTTP 501 if it is not set
48
+ useSLASPrivateClient: false
33
49
  }
34
50
 
35
51
  const runtime = getRuntime()
@@ -67,6 +83,7 @@ const {handler} = runtime.createHandler(options, (app) => {
67
83
  res.set('Cache-Control', `max-age=31536000`)
68
84
  res.send()
69
85
  })
86
+
70
87
  app.get('/robots.txt', runtime.serveStaticFile('static/robots.txt'))
71
88
  app.get('/favicon.ico', runtime.serveStaticFile('static/ico/favicon.ico'))
72
89
 
@@ -879,12 +879,24 @@
879
879
  "value": "No, keep item"
880
880
  }
881
881
  ],
882
+ "confirmation_modal.remove_cart_item.action.remove": [
883
+ {
884
+ "type": 0,
885
+ "value": "Remove"
886
+ }
887
+ ],
882
888
  "confirmation_modal.remove_cart_item.action.yes": [
883
889
  {
884
890
  "type": 0,
885
891
  "value": "Yes, remove item"
886
892
  }
887
893
  ],
894
+ "confirmation_modal.remove_cart_item.message.need_to_remove_due_to_unavailability": [
895
+ {
896
+ "type": 0,
897
+ "value": "Some items are no longer available online and will be removed from your cart."
898
+ }
899
+ ],
888
900
  "confirmation_modal.remove_cart_item.message.sure_to_remove": [
889
901
  {
890
902
  "type": 0,
@@ -897,6 +909,12 @@
897
909
  "value": "Confirm Remove Item"
898
910
  }
899
911
  ],
912
+ "confirmation_modal.remove_cart_item.title.items_unavailable": [
913
+ {
914
+ "type": 0,
915
+ "value": "Items Unavailable"
916
+ }
917
+ ],
900
918
  "confirmation_modal.remove_wishlist_item.action.no": [
901
919
  {
902
920
  "type": 0,
@@ -1637,6 +1655,12 @@
1637
1655
  "value": "Sale"
1638
1656
  }
1639
1657
  ],
1658
+ "item_image.label.unavailable": [
1659
+ {
1660
+ "type": 0,
1661
+ "value": "Unavailable"
1662
+ }
1663
+ ],
1640
1664
  "item_price.label.starting_at": [
1641
1665
  {
1642
1666
  "type": 0,
@@ -879,12 +879,24 @@
879
879
  "value": "No, keep item"
880
880
  }
881
881
  ],
882
+ "confirmation_modal.remove_cart_item.action.remove": [
883
+ {
884
+ "type": 0,
885
+ "value": "Remove"
886
+ }
887
+ ],
882
888
  "confirmation_modal.remove_cart_item.action.yes": [
883
889
  {
884
890
  "type": 0,
885
891
  "value": "Yes, remove item"
886
892
  }
887
893
  ],
894
+ "confirmation_modal.remove_cart_item.message.need_to_remove_due_to_unavailability": [
895
+ {
896
+ "type": 0,
897
+ "value": "Some items are no longer available online and will be removed from your cart."
898
+ }
899
+ ],
888
900
  "confirmation_modal.remove_cart_item.message.sure_to_remove": [
889
901
  {
890
902
  "type": 0,
@@ -897,6 +909,12 @@
897
909
  "value": "Confirm Remove Item"
898
910
  }
899
911
  ],
912
+ "confirmation_modal.remove_cart_item.title.items_unavailable": [
913
+ {
914
+ "type": 0,
915
+ "value": "Items Unavailable"
916
+ }
917
+ ],
900
918
  "confirmation_modal.remove_wishlist_item.action.no": [
901
919
  {
902
920
  "type": 0,
@@ -1637,6 +1655,12 @@
1637
1655
  "value": "Sale"
1638
1656
  }
1639
1657
  ],
1658
+ "item_image.label.unavailable": [
1659
+ {
1660
+ "type": 0,
1661
+ "value": "Unavailable"
1662
+ }
1663
+ ],
1640
1664
  "item_price.label.starting_at": [
1641
1665
  {
1642
1666
  "type": 0,
@@ -1791,6 +1791,20 @@
1791
1791
  "value": "]"
1792
1792
  }
1793
1793
  ],
1794
+ "confirmation_modal.remove_cart_item.action.remove": [
1795
+ {
1796
+ "type": 0,
1797
+ "value": "["
1798
+ },
1799
+ {
1800
+ "type": 0,
1801
+ "value": "Řḗḗḿǿǿṽḗḗ"
1802
+ },
1803
+ {
1804
+ "type": 0,
1805
+ "value": "]"
1806
+ }
1807
+ ],
1794
1808
  "confirmation_modal.remove_cart_item.action.yes": [
1795
1809
  {
1796
1810
  "type": 0,
@@ -1805,6 +1819,20 @@
1805
1819
  "value": "]"
1806
1820
  }
1807
1821
  ],
1822
+ "confirmation_modal.remove_cart_item.message.need_to_remove_due_to_unavailability": [
1823
+ {
1824
+ "type": 0,
1825
+ "value": "["
1826
+ },
1827
+ {
1828
+ "type": 0,
1829
+ "value": "Şǿǿḿḗḗ īŧḗḗḿş ȧȧřḗḗ ƞǿǿ ŀǿǿƞɠḗḗř ȧȧṽȧȧīŀȧȧƀŀḗḗ ǿǿƞŀīƞḗḗ ȧȧƞḓ ẇīŀŀ ƀḗḗ řḗḗḿǿǿṽḗḗḓ ƒřǿǿḿ ẏǿǿŭŭř ƈȧȧřŧ."
1830
+ },
1831
+ {
1832
+ "type": 0,
1833
+ "value": "]"
1834
+ }
1835
+ ],
1808
1836
  "confirmation_modal.remove_cart_item.message.sure_to_remove": [
1809
1837
  {
1810
1838
  "type": 0,
@@ -1833,6 +1861,20 @@
1833
1861
  "value": "]"
1834
1862
  }
1835
1863
  ],
1864
+ "confirmation_modal.remove_cart_item.title.items_unavailable": [
1865
+ {
1866
+ "type": 0,
1867
+ "value": "["
1868
+ },
1869
+ {
1870
+ "type": 0,
1871
+ "value": "Īŧḗḗḿş Ŭƞȧȧṽȧȧīŀȧȧƀŀḗḗ"
1872
+ },
1873
+ {
1874
+ "type": 0,
1875
+ "value": "]"
1876
+ }
1877
+ ],
1836
1878
  "confirmation_modal.remove_wishlist_item.action.no": [
1837
1879
  {
1838
1880
  "type": 0,
@@ -3453,6 +3495,20 @@
3453
3495
  "value": "]"
3454
3496
  }
3455
3497
  ],
3498
+ "item_image.label.unavailable": [
3499
+ {
3500
+ "type": 0,
3501
+ "value": "["
3502
+ },
3503
+ {
3504
+ "type": 0,
3505
+ "value": "Ŭƞȧȧṽȧȧīŀȧȧƀŀḗḗ"
3506
+ },
3507
+ {
3508
+ "type": 0,
3509
+ "value": "]"
3510
+ }
3511
+ ],
3456
3512
  "item_price.label.starting_at": [
3457
3513
  {
3458
3514
  "type": 0,
@@ -130,6 +130,7 @@ export const TestProviders = ({
130
130
  organizationId={commerceApiConfig.parameters.organizationId}
131
131
  siteId={site?.id}
132
132
  locale={locale.id}
133
+ proxy={`${window.location.origin}/${commerceApiConfig.proxyPath}`}
133
134
  redirectURI={`${window.location.origin}/testcallback`}
134
135
  fetchedToken={bypassAuth ? (isGuest ? guestToken : registerUserToken) : ''}
135
136
  >
package/app/utils/url.js CHANGED
@@ -147,8 +147,6 @@ export const getPathWithLocale = (shortCode, buildUrl, opts = {}) => {
147
147
  // remove ending any &
148
148
  search = search.replace(/&$/, '')
149
149
 
150
- const defaultSite = getDefaultSite()
151
-
152
150
  // Remove query parameters
153
151
  const {disallowParams = []} = opts
154
152
 
@@ -161,7 +159,6 @@ export const getPathWithLocale = (shortCode, buildUrl, opts = {}) => {
161
159
  }
162
160
 
163
161
  const site = getSiteByReference(siteRef)
164
-
165
162
  const locale = getLocaleByReference(site, shortCode)
166
163
 
167
164
  // rebuild the url with new locale,
@@ -169,7 +166,7 @@ export const getPathWithLocale = (shortCode, buildUrl, opts = {}) => {
169
166
  `${pathname}${Array.from(queryString).length !== 0 ? `?${queryString}` : ''}`,
170
167
  // By default, as for home page, when the values of site and locale belongs to the default site,
171
168
  // they will be not shown in the url just
172
- defaultSite.alias || defaultSite.id,
169
+ site.alias || site.id,
173
170
  locale?.alias || locale?.id
174
171
  )
175
172
  return newUrl
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/retail-react-app",
3
- "version": "2.3.1",
3
+ "version": "2.4.0-dev.1",
4
4
  "license": "See license in LICENSE",
5
5
  "author": "cc-pwa-kit@salesforce.com",
6
6
  "ccExtensibility": {
@@ -45,10 +45,10 @@
45
45
  "@lhci/cli": "^0.11.0",
46
46
  "@loadable/component": "^5.15.3",
47
47
  "@peculiar/webcrypto": "^1.4.2",
48
- "@salesforce/commerce-sdk-react": "1.3.0",
49
- "@salesforce/pwa-kit-dev": "3.4.0",
50
- "@salesforce/pwa-kit-react-sdk": "3.4.0",
51
- "@salesforce/pwa-kit-runtime": "3.4.0",
48
+ "@salesforce/commerce-sdk-react": "1.4.0-dev.1",
49
+ "@salesforce/pwa-kit-dev": "3.5.0-alpha.1",
50
+ "@salesforce/pwa-kit-react-sdk": "3.5.0-alpha.1",
51
+ "@salesforce/pwa-kit-runtime": "3.5.0-alpha.1",
52
52
  "@tanstack/react-query": "^4.28.0",
53
53
  "@tanstack/react-query-devtools": "^4.29.1",
54
54
  "@testing-library/dom": "^9.0.1",
@@ -100,5 +100,5 @@
100
100
  "maxSize": "320 kB"
101
101
  }
102
102
  ],
103
- "gitHead": "41c7e7d585508f5b0f259e7d80dce8aff5df24f9"
103
+ "gitHead": "2df9f520e6de6585926743fb72bf8e77d515dcf1"
104
104
  }
@@ -343,15 +343,24 @@
343
343
  "confirmation_modal.remove_cart_item.action.no": {
344
344
  "defaultMessage": "No, keep item"
345
345
  },
346
+ "confirmation_modal.remove_cart_item.action.remove": {
347
+ "defaultMessage": "Remove"
348
+ },
346
349
  "confirmation_modal.remove_cart_item.action.yes": {
347
350
  "defaultMessage": "Yes, remove item"
348
351
  },
352
+ "confirmation_modal.remove_cart_item.message.need_to_remove_due_to_unavailability": {
353
+ "defaultMessage": "Some items are no longer available online and will be removed from your cart."
354
+ },
349
355
  "confirmation_modal.remove_cart_item.message.sure_to_remove": {
350
356
  "defaultMessage": "Are you sure you want to remove this item from your cart?"
351
357
  },
352
358
  "confirmation_modal.remove_cart_item.title.confirm_remove": {
353
359
  "defaultMessage": "Confirm Remove Item"
354
360
  },
361
+ "confirmation_modal.remove_cart_item.title.items_unavailable": {
362
+ "defaultMessage": "Items Unavailable"
363
+ },
355
364
  "confirmation_modal.remove_wishlist_item.action.no": {
356
365
  "defaultMessage": "No, keep item"
357
366
  },
@@ -686,6 +695,10 @@
686
695
  "defaultMessage": "Sale",
687
696
  "description": "A sale badge placed on top of a product image"
688
697
  },
698
+ "item_image.label.unavailable": {
699
+ "defaultMessage": "Unavailable",
700
+ "description": "A unavailable badge placed on top of a product image"
701
+ },
689
702
  "item_price.label.starting_at": {
690
703
  "defaultMessage": "Starting at"
691
704
  },
@@ -343,15 +343,24 @@
343
343
  "confirmation_modal.remove_cart_item.action.no": {
344
344
  "defaultMessage": "No, keep item"
345
345
  },
346
+ "confirmation_modal.remove_cart_item.action.remove": {
347
+ "defaultMessage": "Remove"
348
+ },
346
349
  "confirmation_modal.remove_cart_item.action.yes": {
347
350
  "defaultMessage": "Yes, remove item"
348
351
  },
352
+ "confirmation_modal.remove_cart_item.message.need_to_remove_due_to_unavailability": {
353
+ "defaultMessage": "Some items are no longer available online and will be removed from your cart."
354
+ },
349
355
  "confirmation_modal.remove_cart_item.message.sure_to_remove": {
350
356
  "defaultMessage": "Are you sure you want to remove this item from your cart?"
351
357
  },
352
358
  "confirmation_modal.remove_cart_item.title.confirm_remove": {
353
359
  "defaultMessage": "Confirm Remove Item"
354
360
  },
361
+ "confirmation_modal.remove_cart_item.title.items_unavailable": {
362
+ "defaultMessage": "Items Unavailable"
363
+ },
355
364
  "confirmation_modal.remove_wishlist_item.action.no": {
356
365
  "defaultMessage": "No, keep item"
357
366
  },
@@ -686,6 +695,10 @@
686
695
  "defaultMessage": "Sale",
687
696
  "description": "A sale badge placed on top of a product image"
688
697
  },
698
+ "item_image.label.unavailable": {
699
+ "defaultMessage": "Unavailable",
700
+ "description": "A unavailable badge placed on top of a product image"
701
+ },
689
702
  "item_price.label.starting_at": {
690
703
  "defaultMessage": "Starting at"
691
704
  },