@magento/peregrine 14.2.1 → 14.3.1-alpha.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.
@@ -0,0 +1,10 @@
1
+ const SUPPORTED_PRODUCT_TYPES = [
2
+ 'SimpleProduct',
3
+ 'ConfigurableProduct',
4
+ 'configurable',
5
+ 'simple'
6
+ ];
7
+
8
+ export const isSupportedProductType = productType => {
9
+ return SUPPORTED_PRODUCT_TYPES.includes(productType);
10
+ };
@@ -38,10 +38,16 @@ export const useAddToCartButton = props => {
38
38
 
39
39
  const isInStock = item.stock_status === 'IN_STOCK';
40
40
 
41
- const productType = item.__typename;
41
+ const productType = item
42
+ ? item.__typename !== undefined
43
+ ? item.__typename
44
+ : item.type
45
+ : null;
46
+
42
47
  const isUnsupportedProductType = UNSUPPORTED_PRODUCT_TYPES.includes(
43
48
  productType
44
49
  );
50
+
45
51
  const isDisabled = isLoading || !isInStock || isUnsupportedProductType;
46
52
 
47
53
  const history = useHistory();
@@ -52,7 +58,7 @@ export const useAddToCartButton = props => {
52
58
 
53
59
  const handleAddToCart = useCallback(async () => {
54
60
  try {
55
- if (productType === 'SimpleProduct') {
61
+ if (productType === 'SimpleProduct' || productType === 'simple') {
56
62
  setIsLoading(true);
57
63
 
58
64
  const quantity = 1;
@@ -97,7 +103,10 @@ export const useAddToCartButton = props => {
97
103
  });
98
104
 
99
105
  setIsLoading(false);
100
- } else if (productType === 'ConfigurableProduct') {
106
+ } else if (
107
+ productType === 'ConfigurableProduct' ||
108
+ productType === 'configurable'
109
+ ) {
101
110
  const productLink = resourceUrl(
102
111
  `/${item.url_key}${urlSuffix || ''}`
103
112
  );
@@ -1,4 +1,4 @@
1
- import { isSupportedProductType as isSupported } from '@magento/peregrine/lib/util/isSupportedProductType';
1
+ import { isSupportedProductType as isSupported } from './isSupportedProductType';
2
2
  import { useEventingContext } from '@magento/peregrine/lib/context/eventing';
3
3
  import { useCallback, useEffect, useRef } from 'react';
4
4
  import { useIntersectionObserver } from '@magento/peregrine/lib/hooks/useIntersectionObserver';
@@ -81,8 +81,11 @@ export const useGalleryItem = (props = {}) => {
81
81
  item
82
82
  ]);
83
83
 
84
- const productType = item ? item.__typename : null;
85
-
84
+ const productType = item
85
+ ? item.__typename !== undefined
86
+ ? item.__typename
87
+ : item.type
88
+ : null;
86
89
  const isSupportedProductType = isSupported(productType);
87
90
 
88
91
  const wishlistButtonProps =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magento/peregrine",
3
- "version": "14.2.1",
3
+ "version": "14.3.1-alpha.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -49,7 +49,7 @@
49
49
  "redux-actions": "~2.6.5"
50
50
  },
51
51
  "engines": {
52
- "node": ">=14.x",
52
+ "node": ">=18.x",
53
53
  "yarn": ">=1.12.0"
54
54
  },
55
55
  "pwa-studio": {