@magento/peregrine 12.1.0 → 12.2.0-alpha.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 (110) hide show
  1. package/lib/Apollo/clearCartDataFromCache.js +11 -12
  2. package/lib/Apollo/clearCustomerDataFromCache.js +15 -8
  3. package/lib/Apollo/policies/index.js +35 -3
  4. package/lib/Toasts/useToasts.js +5 -0
  5. package/lib/hooks/useCustomerWishlistSkus/customerWishlist.gql.ce.js +3 -3
  6. package/lib/store/actions/cart/asyncActions.js +1 -2
  7. package/lib/store/actions/user/asyncActions.js +2 -4
  8. package/lib/store/reducers/catalog.js +7 -7
  9. package/lib/store/reducers/user.js +1 -3
  10. package/lib/talons/Adapter/useAdapter.js +80 -11
  11. package/lib/talons/AddToCartDialog/addToCartDialog.gql.js +2 -2
  12. package/lib/talons/AddressBookPage/addressBookPage.gql.js +3 -9
  13. package/lib/talons/Breadcrumbs/breadcrumbs.gql.js +16 -12
  14. package/lib/talons/Breadcrumbs/useBreadcrumbs.js +6 -4
  15. package/lib/talons/CartPage/GiftCards/giftCardQueries.gql.ee.js +2 -2
  16. package/lib/talons/CartPage/PriceAdjustments/CouponCode/couponCode.gql.js +2 -3
  17. package/lib/talons/CartPage/PriceAdjustments/ShippingMethods/shippingMethods.gql.js +1 -1
  18. package/lib/talons/CartPage/PriceSummary/priceSummaryFragments.gql.js +2 -1
  19. package/lib/talons/CartPage/ProductListing/EditModal/productForm.gql.js +3 -3
  20. package/lib/talons/CartPage/ProductListing/EditModal/productFormFragment.gql.js +6 -3
  21. package/lib/talons/CartPage/ProductListing/EditModal/useProductForm.js +1 -0
  22. package/lib/talons/CartPage/ProductListing/product.gql.js +2 -1
  23. package/lib/talons/CartPage/ProductListing/productListing.gql.ce.js +2 -1
  24. package/lib/talons/CartPage/ProductListing/productListing.gql.ee.js +2 -1
  25. package/lib/talons/CartPage/ProductListing/productListingFragments.gql.js +14 -5
  26. package/lib/talons/CartPage/ProductListing/useProduct.js +8 -1
  27. package/lib/talons/CartPage/ProductListing/useProductListing.js +4 -2
  28. package/lib/talons/CartPage/useCartPage.js +4 -3
  29. package/lib/talons/CategoryList/categoryList.gql.js +25 -17
  30. package/lib/talons/CategoryList/useCategoryList.js +6 -1
  31. package/lib/talons/CategoryList/useCategoryTile.js +2 -0
  32. package/lib/talons/CategoryTree/categoryTree.gql.js +18 -12
  33. package/lib/talons/CategoryTree/useCategoryBranch.js +1 -1
  34. package/lib/talons/CategoryTree/useCategoryTree.js +5 -5
  35. package/lib/talons/CheckoutPage/AddressBook/addressBook.gql.js +1 -1
  36. package/lib/talons/CheckoutPage/BillingAddress/billingAddress.gql.js +1 -1
  37. package/lib/talons/CheckoutPage/ItemsReview/__fixtures__/cartItems.js +12 -12
  38. package/lib/talons/CheckoutPage/ItemsReview/itemsReview.gql.js +2 -1
  39. package/lib/talons/CheckoutPage/ItemsReview/itemsReviewFragments.gql.js +11 -5
  40. package/lib/talons/CheckoutPage/OrderConfirmationPage/createAccount.gql.js +12 -6
  41. package/lib/talons/CheckoutPage/PaymentInformation/creditCard.gql.js +2 -2
  42. package/lib/talons/CheckoutPage/PaymentInformation/paymentInformation.gql.js +2 -2
  43. package/lib/talons/CheckoutPage/ShippingInformation/AddressForm/customerForm.gql.js +3 -5
  44. package/lib/talons/CheckoutPage/ShippingInformation/AddressForm/guestForm.gql.js +12 -4
  45. package/lib/talons/CheckoutPage/ShippingInformation/AddressForm/useGuestForm.js +45 -5
  46. package/lib/talons/CheckoutPage/ShippingInformation/shippingInformation.gql.js +2 -2
  47. package/lib/talons/CheckoutPage/ShippingMethod/shippingMethod.gql.js +1 -1
  48. package/lib/talons/CheckoutPage/checkoutPage.gql.js +2 -2
  49. package/lib/talons/CheckoutPage/checkoutPageFragments.gql.js +4 -2
  50. package/lib/talons/CheckoutPage/useCheckoutPage.js +5 -2
  51. package/lib/talons/Cms/cmsPage.gql.js +0 -4
  52. package/lib/talons/Cms/useCmsPage.js +6 -23
  53. package/lib/talons/CommunicationsPage/communicationsPage.gql.js +2 -2
  54. package/lib/talons/ContactPage/contactUs.gql.js +48 -0
  55. package/lib/talons/ContactPage/index.js +2 -0
  56. package/lib/talons/ContactPage/useContactLink.js +27 -0
  57. package/lib/talons/ContactPage/useContactPage.js +85 -0
  58. package/lib/talons/CreateAccount/createAccount.gql.js +15 -8
  59. package/lib/talons/CreateAccount/useCreateAccount.js +2 -4
  60. package/lib/talons/Footer/footer.gql.js +2 -1
  61. package/lib/talons/FormError/useFormError.js +9 -7
  62. package/lib/talons/Gallery/__fixtures__/apolloMocks.js +2 -2
  63. package/lib/talons/Gallery/gallery.gql.ce.js +2 -1
  64. package/lib/talons/Gallery/gallery.gql.ee.js +2 -1
  65. package/lib/talons/Gallery/useAddToCartButton.js +12 -11
  66. package/lib/talons/Header/storeSwitcher.gql.js +21 -9
  67. package/lib/talons/Header/useCartTrigger.js +3 -3
  68. package/lib/talons/Header/useStoreSwitcher.js +10 -8
  69. package/lib/talons/MagentoRoute/magentoRoute.gql.js +4 -2
  70. package/lib/talons/MagentoRoute/useMagentoRoute.js +39 -33
  71. package/lib/talons/MegaMenu/megaMenu.gql.js +10 -5
  72. package/lib/talons/MegaMenu/useMegaMenu.js +3 -5
  73. package/lib/talons/MegaMenu/useMegaMenuItem.js +5 -0
  74. package/lib/talons/MiniCart/ProductList/productListFragments.gql.js +10 -5
  75. package/lib/talons/MiniCart/miniCart.gql.js +2 -1
  76. package/lib/talons/MiniCart/useMiniCart.js +8 -7
  77. package/lib/talons/Navigation/navigation.gql.js +4 -3
  78. package/lib/talons/Navigation/useNavigation.js +1 -1
  79. package/lib/talons/Newsletter/newsletter.gql.js +14 -1
  80. package/lib/talons/Newsletter/useNewsletter.js +31 -12
  81. package/lib/talons/OrderHistoryPage/orderHistoryContext.gql.js +2 -1
  82. package/lib/talons/OrderHistoryPage/orderHistoryPage.gql.js +1 -1
  83. package/lib/talons/OrderHistoryPage/orderRow.gql.js +7 -3
  84. package/lib/talons/ProductFullDetail/CustomAttributes/AttributeType/useAttributeType.js +26 -0
  85. package/lib/talons/ProductFullDetail/productFullDetail.gql.ce.js +4 -3
  86. package/lib/talons/ProductFullDetail/productFullDetail.gql.ee.js +2 -1
  87. package/lib/talons/ProductFullDetail/useProductFullDetail.js +28 -2
  88. package/lib/talons/RootComponents/Category/category.gql.js +7 -4
  89. package/lib/talons/RootComponents/Category/categoryContent.gql.js +26 -7
  90. package/lib/talons/RootComponents/Category/categoryFragments.gql.js +4 -2
  91. package/lib/talons/RootComponents/Category/useCategory.js +8 -6
  92. package/lib/talons/RootComponents/Category/useCategoryContent.js +30 -3
  93. package/lib/talons/RootComponents/Category/useNoProductsFound.js +0 -1
  94. package/lib/talons/RootComponents/Product/product.gql.js +2 -1
  95. package/lib/talons/RootComponents/Product/productDetailFragment.gql.js +66 -10
  96. package/lib/talons/SearchPage/searchPage.gql.js +17 -2
  97. package/lib/talons/SearchPage/useSearchPage.js +25 -0
  98. package/lib/talons/SignIn/signIn.gql.js +4 -3
  99. package/lib/talons/SignIn/useSignIn.js +2 -4
  100. package/lib/talons/Wishlist/WishlistDialog/wishlistDialog.gql.js +3 -2
  101. package/lib/talons/WishlistPage/createWishlist.gql.js +2 -1
  102. package/lib/talons/WishlistPage/useWishlistItem.js +2 -2
  103. package/lib/talons/WishlistPage/wishlist.gql.js +2 -2
  104. package/lib/talons/WishlistPage/wishlistConfig.gql.ce.js +2 -1
  105. package/lib/talons/WishlistPage/wishlistConfig.gql.ee.js +2 -1
  106. package/lib/talons/WishlistPage/wishlistItemFragments.gql.js +5 -2
  107. package/lib/talons/WishlistPage/wishlistPage.gql.js +1 -1
  108. package/package.json +6 -6
  109. package/lib/Apollo/clearStore.js +0 -26
  110. package/lib/Apollo/deleteCacheEntry.js +0 -87
@@ -1,15 +1,23 @@
1
- import { useCallback, useMemo } from 'react';
2
- import { useMutation } from '@apollo/client';
1
+ import { useCallback, useMemo, useState, useEffect } from 'react';
2
+ import { useMutation, useLazyQuery } from '@apollo/client';
3
3
  import DEFAULT_OPERATIONS from './guestForm.gql';
4
4
  import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
5
5
 
6
6
  import { useCartContext } from '../../../../context/cart';
7
7
 
8
8
  export const useGuestForm = props => {
9
- const { afterSubmit, onCancel, onSuccess, shippingData } = props;
9
+ const {
10
+ afterSubmit,
11
+ onCancel,
12
+ onSuccess,
13
+ shippingData,
14
+ toggleSignInContent,
15
+ setGuestSignInUsername
16
+ } = props;
17
+ const [showSignInToast, setShowSignInToast] = useState(false);
10
18
 
11
19
  const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
12
- const { setGuestShippingMutation } = operations;
20
+ const { setGuestShippingMutation, getEmailAvailableQuery } = operations;
13
21
 
14
22
  const [{ cartId }] = useCartContext();
15
23
 
@@ -22,6 +30,10 @@ export const useGuestForm = props => {
22
30
  }
23
31
  );
24
32
 
33
+ const [runQuery, { data }] = useLazyQuery(getEmailAvailableQuery, {
34
+ fetchPolicy: 'cache-and-network'
35
+ });
36
+
25
37
  const { country } = shippingData;
26
38
  const { code: countryCode } = country;
27
39
 
@@ -66,17 +78,45 @@ export const useGuestForm = props => {
66
78
  onCancel();
67
79
  }, [onCancel]);
68
80
 
81
+ const handleValidateEmail = useCallback(
82
+ email => {
83
+ setShowSignInToast(false);
84
+ if (email && email.includes('@')) {
85
+ runQuery({ variables: { email } });
86
+ }
87
+ },
88
+ [runQuery]
89
+ );
90
+
91
+ const handleToastAction = useCallback(
92
+ (removeToast, email) => {
93
+ setGuestSignInUsername(email);
94
+ toggleSignInContent();
95
+ removeToast();
96
+ },
97
+ [setGuestSignInUsername, toggleSignInContent]
98
+ );
99
+
69
100
  const errors = useMemo(
70
101
  () => new Map([['setGuestShippingMutation', error]]),
71
102
  [error]
72
103
  );
73
104
 
105
+ useEffect(() => {
106
+ if (data) {
107
+ setShowSignInToast(!data.isEmailAvailable.is_email_available);
108
+ }
109
+ }, [data]);
110
+
74
111
  return {
75
112
  errors,
76
113
  handleCancel,
77
114
  handleSubmit,
115
+ handleValidateEmail,
116
+ handleToastAction,
78
117
  initialValues,
79
118
  isSaving: loading,
80
- isUpdate
119
+ isUpdate,
120
+ showSignInToast
81
121
  };
82
122
  };
@@ -17,8 +17,8 @@ export const GET_SHIPPING_INFORMATION = gql`
17
17
 
18
18
  export const GET_DEFAULT_SHIPPING = gql`
19
19
  query GetDefaultShipping {
20
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
20
21
  customer {
21
- id
22
22
  default_shipping
23
23
  }
24
24
  }
@@ -31,7 +31,7 @@ export const SET_CUSTOMER_ADDRESS_ON_CART = gql`
31
31
  cart_id: $cartId
32
32
  shipping_addresses: [{ customer_address_id: $addressId }]
33
33
  }
34
- ) @connection(key: "setShippingAddressesOnCart") {
34
+ ) {
35
35
  cart {
36
36
  id
37
37
  ...ShippingInformationFragment
@@ -33,7 +33,7 @@ export const SET_SHIPPING_METHOD = gql`
33
33
  ) {
34
34
  setShippingMethodsOnCart(
35
35
  input: { cart_id: $cartId, shipping_methods: [$shippingMethod] }
36
- ) @connection(key: "setShippingMethodsOnCart") {
36
+ ) {
37
37
  cart {
38
38
  id
39
39
  # If this mutation causes "free" to become available we need to know.
@@ -12,7 +12,7 @@ export const CREATE_CART = gql`
12
12
 
13
13
  export const PLACE_ORDER = gql`
14
14
  mutation placeOrder($cartId: String!) {
15
- placeOrder(input: { cart_id: $cartId }) @connection(key: "placeOrder") {
15
+ placeOrder(input: { cart_id: $cartId }) {
16
16
  order {
17
17
  order_number
18
18
  }
@@ -44,8 +44,8 @@ export const GET_CHECKOUT_DETAILS = gql`
44
44
 
45
45
  export const GET_CUSTOMER = gql`
46
46
  query GetCustomerForCheckout {
47
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
47
48
  customer {
48
- id
49
49
  default_shipping
50
50
  firstname
51
51
  }
@@ -3,10 +3,12 @@ import { gql } from '@apollo/client';
3
3
  export const CheckoutPageFragment = gql`
4
4
  fragment CheckoutPageFragment on Cart {
5
5
  id
6
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
6
7
  items {
7
- id
8
+ uid
9
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
8
10
  product {
9
- id
11
+ uid
10
12
  stock_status
11
13
  }
12
14
  }
@@ -6,7 +6,6 @@ import {
6
6
  useQuery
7
7
  } from '@apollo/client';
8
8
 
9
- import { clearCartDataFromCache } from '../../Apollo/clearCartDataFromCache';
10
9
  import { useUserContext } from '../../context/user';
11
10
  import { useCartContext } from '../../context/cart';
12
11
 
@@ -88,6 +87,8 @@ export const useCheckoutPage = (props = {}) => {
88
87
  const [checkoutStep, setCheckoutStep] = useState(
89
88
  CHECKOUT_STEP.SHIPPING_ADDRESS
90
89
  );
90
+ const [guestSignInUsername, setGuestSignInUsername] = useState('');
91
+
91
92
  const [{ isSignedIn }] = useUserContext();
92
93
  const [{ cartId }, { createCart, removeCart }] = useCartContext();
93
94
 
@@ -246,7 +247,7 @@ export const useCheckoutPage = (props = {}) => {
246
247
  });
247
248
  // Cleanup stale cart and customer info.
248
249
  await removeCart();
249
- await clearCartDataFromCache(apolloClient);
250
+ await apolloClient.clearCacheData(apolloClient, 'cart');
250
251
 
251
252
  await createCart({
252
253
  fetchCartId
@@ -285,6 +286,7 @@ export const useCheckoutPage = (props = {}) => {
285
286
  checkoutStep,
286
287
  customer,
287
288
  error: checkoutError,
289
+ guestSignInUsername,
288
290
  handlePlaceOrder,
289
291
  hasError: !!checkoutError,
290
292
  isCartEmpty: !(checkoutData && checkoutData.cart.total_quantity),
@@ -298,6 +300,7 @@ export const useCheckoutPage = (props = {}) => {
298
300
  null,
299
301
  placeOrderLoading,
300
302
  setCheckoutStep,
303
+ setGuestSignInUsername,
301
304
  setIsUpdating,
302
305
  setShippingInformationDone,
303
306
  setShippingMethodDone,
@@ -12,10 +12,6 @@ export const GET_CMS_PAGE = gql`
12
12
  meta_keywords
13
13
  meta_description
14
14
  }
15
- storeConfig {
16
- id
17
- root_category_id
18
- }
19
15
  }
20
16
  `;
21
17
 
@@ -1,4 +1,4 @@
1
- import { useEffect, useMemo } from 'react';
1
+ import { useEffect } from 'react';
2
2
  import { useQuery } from '@apollo/client';
3
3
 
4
4
  import mergeOperations from '../../util/shallowMerge';
@@ -9,11 +9,10 @@ import DEFAULT_OPERATIONS from './cmsPage.gql';
9
9
  /**
10
10
  * Retrieves data necessary to render a CMS Page
11
11
  *
12
- * @param {object} props
13
- * @param {object} props.id - CMS Page ID
14
- * @param {object} props.queries - Collection of GraphQL queries
15
- * @param {object} props.queries.getCmsPage - Query for getting a CMS Page
16
- * @returns {{shouldShowLoadingIndicator: *, hasContent: *, cmsPage: *, error: *}}
12
+ * @param {{identifier}} props
13
+ * @param {String} props.identifier - CMS Page Identifier
14
+ * @param {Object} props.operations - Collection of GraphQL queries
15
+ * @returns {{cmsPage: *, shouldShowLoadingIndicator: *}}
17
16
  */
18
17
  export const useCmsPage = props => {
19
18
  const { identifier } = props;
@@ -21,7 +20,7 @@ export const useCmsPage = props => {
21
20
  const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
22
21
  const { getCMSPageQuery } = operations;
23
22
 
24
- const { loading, error, data } = useQuery(getCMSPageQuery, {
23
+ const { loading, data } = useQuery(getCMSPageQuery, {
25
24
  variables: {
26
25
  identifier: identifier
27
26
  },
@@ -51,25 +50,9 @@ export const useCmsPage = props => {
51
50
  const shouldShowLoadingIndicator = loading && !data;
52
51
 
53
52
  const cmsPage = data ? data.cmsPage : null;
54
- const rootCategoryId = data ? data.storeConfig.root_category_id : null;
55
-
56
- // Only render <RichContent /> if the page isn't empty and doesn't contain
57
- // the default CMS Page text. We do this so there is at least a useable home
58
- // page by default, the category list component.
59
- const hasContent = useMemo(() => {
60
- return (
61
- cmsPage &&
62
- cmsPage.content &&
63
- cmsPage.content.length > 0 &&
64
- !cmsPage.content.includes('CMS homepage content goes here.')
65
- );
66
- }, [cmsPage]);
67
53
 
68
54
  return {
69
55
  cmsPage,
70
- error,
71
- hasContent,
72
- rootCategoryId,
73
56
  shouldShowLoadingIndicator
74
57
  };
75
58
  };
@@ -3,8 +3,8 @@ import { gql } from '@apollo/client';
3
3
  export const SET_NEWSLETTER_SUBSCRIPTION = gql`
4
4
  mutation SetNewsletterSubscription($isSubscribed: Boolean!) {
5
5
  updateCustomer(input: { is_subscribed: $isSubscribed }) {
6
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
6
7
  customer {
7
- id
8
8
  is_subscribed
9
9
  }
10
10
  }
@@ -13,8 +13,8 @@ export const SET_NEWSLETTER_SUBSCRIPTION = gql`
13
13
 
14
14
  export const GET_CUSTOMER_SUBSCRIPTION = gql`
15
15
  query GetCustomerSubscription {
16
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
16
17
  customer {
17
- id
18
18
  is_subscribed
19
19
  }
20
20
  }
@@ -0,0 +1,48 @@
1
+ import { gql } from '@apollo/client';
2
+
3
+ export const SUBMIT_CONTACT_FORM = gql`
4
+ mutation SubmitContactForm(
5
+ $name: String!
6
+ $email: String!
7
+ $comment: String!
8
+ $telephone: String
9
+ ) {
10
+ contactUs(
11
+ input: {
12
+ name: $name
13
+ email: $email
14
+ comment: $comment
15
+ telephone: $telephone
16
+ }
17
+ ) {
18
+ status
19
+ }
20
+ }
21
+ `;
22
+
23
+ export const GET_STORE_CONFIG_DATA = gql`
24
+ query GetStoreConfigForContactUs {
25
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
26
+ storeConfig {
27
+ store_code
28
+ contact_enabled
29
+ }
30
+ }
31
+ `;
32
+
33
+ export const GET_CONTACT_PAGE_CMS_BLOCKS = gql`
34
+ query GetContactPageCmsBlocks($cmsBlockIdentifiers: [String]) {
35
+ cmsBlocks(identifiers: $cmsBlockIdentifiers) {
36
+ items {
37
+ content
38
+ identifier
39
+ }
40
+ }
41
+ }
42
+ `;
43
+
44
+ export default {
45
+ contactMutation: SUBMIT_CONTACT_FORM,
46
+ getStoreConfigQuery: GET_STORE_CONFIG_DATA,
47
+ getContactPageCmsBlocksQuery: GET_CONTACT_PAGE_CMS_BLOCKS
48
+ };
@@ -0,0 +1,2 @@
1
+ export { default as useContactPage } from './useContactPage';
2
+ export { default as useContactLink } from './useContactLink';
@@ -0,0 +1,27 @@
1
+ import { useMemo } from 'react';
2
+ import { useQuery } from '@apollo/client';
3
+ import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
4
+ import DEFAULT_OPERATIONS from './contactUs.gql';
5
+
6
+ export default (props = {}) => {
7
+ const { getStoreConfigQuery } = mergeOperations(
8
+ DEFAULT_OPERATIONS,
9
+ props.operations
10
+ );
11
+
12
+ const { data: storeConfigData, loading: configLoading } = useQuery(
13
+ getStoreConfigQuery,
14
+ {
15
+ fetchPolicy: 'cache-and-network'
16
+ }
17
+ );
18
+
19
+ const isEnabled = useMemo(() => {
20
+ return !!storeConfigData?.storeConfig?.contact_enabled;
21
+ }, [storeConfigData]);
22
+
23
+ return {
24
+ isEnabled,
25
+ isLoading: configLoading
26
+ };
27
+ };
@@ -0,0 +1,85 @@
1
+ import { useCallback, useRef, useMemo } from 'react';
2
+ import { useMutation, useQuery } from '@apollo/client';
3
+ import mergeOperations from '@magento/peregrine/lib/util/shallowMerge';
4
+ import DEFAULT_OPERATIONS from './contactUs.gql';
5
+
6
+ export default props => {
7
+ const { cmsBlockIdentifiers = [], operations } = props;
8
+ const {
9
+ contactMutation,
10
+ getStoreConfigQuery,
11
+ getContactPageCmsBlocksQuery
12
+ } = mergeOperations(DEFAULT_OPERATIONS, operations);
13
+
14
+ const formApiRef = useRef(null);
15
+
16
+ const [
17
+ submitForm,
18
+ { data, error: contactError, loading: submitLoading }
19
+ ] = useMutation(contactMutation, {
20
+ fetchPolicy: 'no-cache'
21
+ });
22
+
23
+ const { data: storeConfigData, loading: configLoading } = useQuery(
24
+ getStoreConfigQuery,
25
+ {
26
+ fetchPolicy: 'cache-and-network'
27
+ }
28
+ );
29
+
30
+ const { data: cmsBlocksData, loading: cmsBlocksLoading } = useQuery(
31
+ getContactPageCmsBlocksQuery,
32
+ {
33
+ variables: {
34
+ cmsBlockIdentifiers
35
+ },
36
+ fetchPolicy: 'cache-and-network'
37
+ }
38
+ );
39
+
40
+ const isEnabled = useMemo(() => {
41
+ return !!storeConfigData?.storeConfig?.contact_enabled;
42
+ }, [storeConfigData]);
43
+
44
+ const cmsBlocks = useMemo(() => {
45
+ return cmsBlocksData?.cmsBlocks?.items || [];
46
+ }, [cmsBlocksData]);
47
+
48
+ const setFormApi = useCallback(api => (formApiRef.current = api), []);
49
+ const handleSubmit = useCallback(
50
+ async ({ name, email, comment, telephone }) => {
51
+ try {
52
+ await submitForm({
53
+ variables: {
54
+ name,
55
+ email,
56
+ comment,
57
+ telephone
58
+ }
59
+ });
60
+ if (formApiRef.current) {
61
+ formApiRef.current.reset();
62
+ }
63
+ } catch (error) {
64
+ if (process.env.NODE_ENV !== 'production') {
65
+ console.error(error);
66
+ }
67
+ }
68
+ },
69
+ [submitForm]
70
+ );
71
+ const errors = useMemo(() => new Map([['contactMutation', contactError]]), [
72
+ contactError
73
+ ]);
74
+
75
+ return {
76
+ isEnabled,
77
+ cmsBlocks,
78
+ errors,
79
+ handleSubmit,
80
+ isBusy: submitLoading,
81
+ isLoading: configLoading && cmsBlocksLoading,
82
+ setFormApi,
83
+ response: data && data.contactUs
84
+ };
85
+ };
@@ -20,8 +20,10 @@ export const CREATE_ACCOUNT = gql`
20
20
  ) {
21
21
  # The createCustomer mutation returns a non-nullable CustomerOutput type
22
22
  # which requires that at least one of the sub fields be returned.
23
+
24
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
23
25
  customer {
24
- id
26
+ email
25
27
  }
26
28
  }
27
29
  }
@@ -29,8 +31,8 @@ export const CREATE_ACCOUNT = gql`
29
31
 
30
32
  export const GET_CUSTOMER = gql`
31
33
  query GetCustomerAfterCreate {
34
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
32
35
  customer {
33
- id
34
36
  email
35
37
  firstname
36
38
  lastname
@@ -57,15 +59,17 @@ export const GET_CART_DETAILS = gql`
57
59
  query GetCartDetailsAfterAccountCreation($cartId: String!) {
58
60
  cart(cart_id: $cartId) {
59
61
  id
62
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
60
63
  items {
61
- id
64
+ uid
62
65
  prices {
63
66
  price {
64
67
  value
65
68
  }
66
69
  }
70
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
67
71
  product {
68
- id
72
+ uid
69
73
  name
70
74
  sku
71
75
  small_image {
@@ -81,11 +85,13 @@ export const GET_CART_DETAILS = gql`
81
85
  }
82
86
  }
83
87
  quantity
88
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
84
89
  ... on ConfigurableCartItem {
90
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
85
91
  configurable_options {
86
- id
92
+ configurable_product_option_uid
87
93
  option_label
88
- value_id
94
+ configurable_product_option_value_uid
89
95
  value_label
90
96
  }
91
97
  }
@@ -108,10 +114,11 @@ export const MERGE_CARTS = gql`
108
114
  mergeCarts(
109
115
  source_cart_id: $sourceCartId
110
116
  destination_cart_id: $destinationCartId
111
- ) @connection(key: "mergeCarts") {
117
+ ) {
112
118
  id
119
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
113
120
  items {
114
- id
121
+ uid
115
122
  }
116
123
  ...CheckoutPageFragment
117
124
  }
@@ -1,8 +1,6 @@
1
1
  import { useCallback, useMemo, useState } from 'react';
2
2
  import { useApolloClient, useMutation } from '@apollo/client';
3
3
 
4
- import { clearCartDataFromCache } from '../../Apollo/clearCartDataFromCache';
5
- import { clearCustomerDataFromCache } from '../../Apollo/clearCustomerDataFromCache';
6
4
  import mergeOperations from '../../util/shallowMerge';
7
5
  import { useUserContext } from '../../context/user';
8
6
  import { useCartContext } from '../../context/cart';
@@ -101,8 +99,8 @@ export const useCreateAccount = props => {
101
99
  await setToken(token);
102
100
 
103
101
  // Clear all cart/customer data from cache and redux.
104
- await clearCartDataFromCache(apolloClient);
105
- await clearCustomerDataFromCache(apolloClient);
102
+ await apolloClient.clearCacheData(apolloClient, 'cart');
103
+ await apolloClient.clearCacheData(apolloClient, 'customer');
106
104
  await removeCart();
107
105
 
108
106
  // Create and get the customer's cart id.
@@ -2,8 +2,9 @@ import { gql } from '@apollo/client';
2
2
 
3
3
  export const GET_COPYRIGHT = gql`
4
4
  query storeConfigData {
5
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
5
6
  storeConfig {
6
- id
7
+ store_code
7
8
  copyright
8
9
  }
9
10
  }
@@ -3,17 +3,19 @@ import { deriveErrorMessage } from '../../util/deriveErrorMessage';
3
3
  import { useIntl } from 'react-intl';
4
4
 
5
5
  export const useFormError = props => {
6
- const { errors } = props;
6
+ const { errors, allowErrorMessages } = props;
7
7
  const { formatMessage } = useIntl();
8
8
 
9
9
  const derivedErrorMessage = useMemo(() => {
10
- const defaultErrorMessage = formatMessage({
11
- id: 'formError.errorMessage',
12
- defaultMessage:
13
- 'An error has occurred. Please check the input and try again.'
14
- });
10
+ const defaultErrorMessage = allowErrorMessages
11
+ ? ''
12
+ : formatMessage({
13
+ id: 'formError.errorMessage',
14
+ defaultMessage:
15
+ 'An error has occurred. Please check the input and try again.'
16
+ });
15
17
  return deriveErrorMessage(errors, defaultErrorMessage);
16
- }, [errors, formatMessage]);
18
+ }, [errors, formatMessage, allowErrorMessages]);
17
19
 
18
20
  return {
19
21
  errorMessage: derivedErrorMessage
@@ -8,7 +8,7 @@ export const mockGetStoreConfigEE = {
8
8
  result: {
9
9
  data: {
10
10
  storeConfig: {
11
- id: 1,
11
+ store_code: 'default',
12
12
  magento_wishlist_general_is_enabled: '1',
13
13
  enable_multiple_wishlists: '1',
14
14
  product_url_suffix: '.html'
@@ -24,7 +24,7 @@ export const mockGetStoreConfigCE = {
24
24
  result: {
25
25
  data: {
26
26
  storeConfig: {
27
- id: 1,
27
+ store_code: 'default',
28
28
  magento_wishlist_general_is_enabled: '1',
29
29
  product_url_suffix: '.html'
30
30
  }
@@ -2,8 +2,9 @@ import { gql } from '@apollo/client';
2
2
 
3
3
  export const GET_STORE_CONFIG_DATA = gql`
4
4
  query GetStoreConfigDataForGalleryCE {
5
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
5
6
  storeConfig {
6
- id
7
+ store_code
7
8
  product_url_suffix
8
9
  magento_wishlist_general_is_enabled
9
10
  }
@@ -2,8 +2,9 @@ import { gql } from '@apollo/client';
2
2
 
3
3
  export const GET_STORE_CONFIG_DATA = gql`
4
4
  query GetStoreConfigDataForGalleryEE {
5
+ # eslint-disable-next-line @graphql-eslint/require-id-when-available
5
6
  storeConfig {
6
- id
7
+ store_code
7
8
  product_url_suffix
8
9
  magento_wishlist_general_is_enabled
9
10
  enable_multiple_wishlists