@magento/peregrine 14.5.1-beta5 → 15.5.1-alpha2

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.
@@ -63,21 +63,33 @@ export const useAddToCartButton = props => {
63
63
 
64
64
  const quantity = 1;
65
65
 
66
- await addToCart({
67
- variables: {
68
- cartId,
69
- cartItem: {
70
- quantity,
71
- entered_options: [
72
- {
73
- uid: item.uid,
74
- value: item.name
75
- }
76
- ],
77
- sku: item.sku
66
+ if (item.uid) {
67
+ await addToCart({
68
+ variables: {
69
+ cartId,
70
+ cartItem: {
71
+ quantity,
72
+ entered_options: [
73
+ {
74
+ uid: item.uid,
75
+ value: item.name
76
+ }
77
+ ],
78
+ sku: item.sku
79
+ }
78
80
  }
79
- }
80
- });
81
+ });
82
+ } else {
83
+ await addToCart({
84
+ variables: {
85
+ cartId,
86
+ cartItem: {
87
+ quantity,
88
+ sku: item.sku
89
+ }
90
+ }
91
+ });
92
+ }
81
93
 
82
94
  dispatch({
83
95
  type: 'CART_ADD_ITEM',
@@ -1,7 +1,9 @@
1
1
  import { gql } from '@apollo/client';
2
2
 
3
3
  export const GET_PRODUCT_FILTERS_BY_CATEGORY = gql`
4
- query getProductFiltersByCategory($filters: ProductAttributeFilterInput!) {
4
+ query getProductFiltersByCategories(
5
+ $filters: ProductAttributeFilterInput!
6
+ ) {
5
7
  products(filter: $filters) {
6
8
  aggregations {
7
9
  label
@@ -27,13 +29,17 @@ export const GET_CATEGORY_CONTENT = gql`
27
29
  description
28
30
  url_key
29
31
  url_path
32
+ display_mode
33
+ cms_block {
34
+ content
35
+ }
30
36
  }
31
37
  }
32
38
  }
33
39
  `;
34
40
 
35
41
  export const GET_CATEGORY_AVAILABLE_SORT_METHODS = gql`
36
- query getCategoryAvailableSortMethods(
42
+ query getCategoriesAvailableSortMethods(
37
43
  $categoryIdFilter: FilterEqualTypeInput!
38
44
  ) {
39
45
  products(filter: { category_uid: $categoryIdFilter }) {
@@ -196,6 +196,14 @@ export const useCategoryContent = props => {
196
196
  const availableSortMethods = sortData
197
197
  ? sortData.products.sort_fields.options
198
198
  : null;
199
+ const categoryDisplayMode =
200
+ categoryData && categoryData.categories.items.length
201
+ ? categoryData.categories.items[0].display_mode
202
+ : null;
203
+ const cmsBlockContent =
204
+ categoryData && categoryData.categories.items.length
205
+ ? categoryData.categories.items[0].cms_block?.content
206
+ : null;
199
207
 
200
208
  useEffect(() => {
201
209
  if (!categoryLoading && categoryData?.categories.items.length > 0) {
@@ -220,6 +228,8 @@ export const useCategoryContent = props => {
220
228
  setFilterOptions,
221
229
  items,
222
230
  totalCount,
223
- totalPagesFromData
231
+ totalPagesFromData,
232
+ categoryDisplayMode,
233
+ cmsBlockContent
224
234
  };
225
235
  };
@@ -9,7 +9,7 @@ const setSearchParams = (existing, options) => {
9
9
  const { categoryId, label, searchValue } = options;
10
10
 
11
11
  params.set('query', searchValue);
12
- params.set('category_id[filter]', `${label}${DELIMITER}${categoryId}`);
12
+ params.set('category_uid[filter]', `${label}${DELIMITER}${categoryId}`);
13
13
 
14
14
  return `${params}`;
15
15
  };
@@ -81,9 +81,8 @@ export const useWishlistItem = props => {
81
81
  selectedConfigurableOptions.length &&
82
82
  selectedConfigurableOptions.length === configurableOptions.length
83
83
  ) {
84
- const selectedOptionsArray = selectedConfigurableOptions.map(
85
- selectedOption => {
86
- // TODO: Use configurable_product_option_uid for ConfigurableWishlistItem when available in 2.4.5
84
+ const selectedOptionsArray = selectedConfigurableOptions
85
+ .map(selectedOption => {
87
86
  const {
88
87
  id: attributeId,
89
88
  value_id: selectedValueId
@@ -91,18 +90,30 @@ export const useWishlistItem = props => {
91
90
  const configurableOption = configurableOptions.find(
92
91
  option => option.attribute_id_v2 === attributeId
93
92
  );
94
- const configurableOptionValue = configurableOption.values.find(
95
- optionValue =>
96
- optionValue.value_index === selectedValueId
97
- );
98
-
99
- return configurableOptionValue.uid;
100
- }
101
- );
93
+ if (configurableOption) {
94
+ const configurableOptionValue = configurableOption.values.find(
95
+ optionValue =>
96
+ optionValue.value_index === selectedValueId
97
+ );
98
+
99
+ if (
100
+ configurableOptionValue &&
101
+ configurableOptionValue.uid
102
+ ) {
103
+ return configurableOptionValue.uid;
104
+ }
105
+ }
106
+ return null;
107
+ })
108
+ .filter(uid => uid !== null);
102
109
 
103
- Object.assign(item, {
104
- selected_options: selectedOptionsArray
105
- });
110
+ if (selectedOptionsArray.length > 0) {
111
+ Object.assign(item, {
112
+ selected_options: selectedOptionsArray
113
+ });
114
+ } else {
115
+ return null;
116
+ }
106
117
  }
107
118
 
108
119
  return item;
@@ -6,6 +6,7 @@ export const WishlistItemFragment = gql`
6
6
  # eslint-disable-next-line @graphql-eslint/require-id-when-available
7
7
  product {
8
8
  uid
9
+ url_key
9
10
  image {
10
11
  label
11
12
  url
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magento/peregrine",
3
- "version": "14.5.1-beta5",
3
+ "version": "15.5.1-alpha2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },