@magento/peregrine 12.0.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.
- package/lib/Apollo/clearCartDataFromCache.js +11 -12
- package/lib/Apollo/clearCustomerDataFromCache.js +15 -8
- package/lib/Apollo/policies/index.js +35 -3
- package/lib/Toasts/useToasts.js +5 -0
- package/lib/context/cart.js +21 -1
- package/lib/hooks/useCustomerWishlistSkus/customerWishlist.gql.ce.js +3 -3
- package/lib/store/actions/cart/asyncActions.js +2 -3
- package/lib/store/actions/user/asyncActions.js +2 -4
- package/lib/store/reducers/catalog.js +7 -7
- package/lib/store/reducers/user.js +1 -3
- package/lib/talons/Adapter/useAdapter.js +80 -11
- package/lib/talons/AddToCartDialog/addToCartDialog.gql.js +2 -2
- package/lib/talons/AddressBookPage/addressBookPage.gql.js +3 -9
- package/lib/talons/Breadcrumbs/breadcrumbs.gql.js +16 -12
- package/lib/talons/Breadcrumbs/useBreadcrumbs.js +6 -4
- package/lib/talons/CartPage/GiftCards/giftCardQueries.gql.ee.js +2 -2
- package/lib/talons/CartPage/PriceAdjustments/CouponCode/couponCode.gql.js +2 -3
- package/lib/talons/CartPage/PriceAdjustments/ShippingMethods/shippingMethods.gql.js +1 -1
- package/lib/talons/CartPage/PriceSummary/priceSummaryFragments.gql.js +2 -1
- package/lib/talons/CartPage/ProductListing/EditModal/__fixtures__/configurableProduct.js +1 -0
- package/lib/talons/CartPage/ProductListing/EditModal/productForm.gql.js +10 -7
- package/lib/talons/CartPage/ProductListing/EditModal/productFormFragment.gql.js +7 -3
- package/lib/talons/CartPage/ProductListing/EditModal/useProductForm.js +3 -2
- package/lib/talons/CartPage/ProductListing/product.gql.js +2 -1
- package/lib/talons/CartPage/ProductListing/productListing.gql.ce.js +2 -1
- package/lib/talons/CartPage/ProductListing/productListing.gql.ee.js +2 -1
- package/lib/talons/CartPage/ProductListing/productListingFragments.gql.js +15 -5
- package/lib/talons/CartPage/ProductListing/useProduct.js +12 -5
- package/lib/talons/CartPage/ProductListing/useProductListing.js +4 -2
- package/lib/talons/CartPage/useCartPage.js +4 -3
- package/lib/talons/CategoryList/categoryList.gql.js +25 -17
- package/lib/talons/CategoryList/useCategoryList.js +6 -1
- package/lib/talons/CategoryList/useCategoryTile.js +2 -0
- package/lib/talons/CategoryTree/categoryTree.gql.js +18 -12
- package/lib/talons/CategoryTree/useCategoryBranch.js +1 -1
- package/lib/talons/CategoryTree/useCategoryTree.js +5 -5
- package/lib/talons/CheckoutPage/AddressBook/addressBook.gql.js +1 -1
- package/lib/talons/CheckoutPage/BillingAddress/billingAddress.gql.js +1 -1
- package/lib/talons/CheckoutPage/ItemsReview/__fixtures__/cartItems.js +12 -12
- package/lib/talons/CheckoutPage/ItemsReview/itemsReview.gql.js +2 -1
- package/lib/talons/CheckoutPage/ItemsReview/itemsReviewFragments.gql.js +11 -5
- package/lib/talons/CheckoutPage/OrderConfirmationPage/createAccount.gql.js +12 -6
- package/lib/talons/CheckoutPage/PaymentInformation/creditCard.gql.js +2 -2
- package/lib/talons/CheckoutPage/PaymentInformation/paymentInformation.gql.js +2 -2
- package/lib/talons/CheckoutPage/ShippingInformation/AddressForm/customerForm.gql.js +3 -5
- package/lib/talons/CheckoutPage/ShippingInformation/AddressForm/guestForm.gql.js +12 -4
- package/lib/talons/CheckoutPage/ShippingInformation/AddressForm/useGuestForm.js +45 -5
- package/lib/talons/CheckoutPage/ShippingInformation/shippingInformation.gql.js +2 -2
- package/lib/talons/CheckoutPage/ShippingMethod/shippingMethod.gql.js +1 -1
- package/lib/talons/CheckoutPage/checkoutPage.gql.js +2 -2
- package/lib/talons/CheckoutPage/checkoutPageFragments.gql.js +4 -2
- package/lib/talons/CheckoutPage/useCheckoutPage.js +5 -2
- package/lib/talons/Cms/cmsPage.gql.js +0 -4
- package/lib/talons/Cms/useCmsPage.js +6 -23
- package/lib/talons/CommunicationsPage/communicationsPage.gql.js +2 -2
- package/lib/talons/ContactPage/contactUs.gql.js +48 -0
- package/lib/talons/ContactPage/index.js +2 -0
- package/lib/talons/ContactPage/useContactLink.js +27 -0
- package/lib/talons/ContactPage/useContactPage.js +85 -0
- package/lib/talons/CreateAccount/createAccount.gql.js +15 -8
- package/lib/talons/CreateAccount/useCreateAccount.js +2 -4
- package/lib/talons/Footer/footer.gql.js +2 -1
- package/lib/talons/FormError/useFormError.js +9 -7
- package/lib/talons/Gallery/__fixtures__/apolloMocks.js +2 -2
- package/lib/talons/Gallery/gallery.gql.ce.js +2 -1
- package/lib/talons/Gallery/gallery.gql.ee.js +2 -1
- package/lib/talons/Gallery/useAddToCartButton.js +28 -13
- package/lib/talons/Header/storeSwitcher.gql.js +21 -9
- package/lib/talons/Header/useCartTrigger.js +3 -3
- package/lib/talons/Header/useStoreSwitcher.js +10 -8
- package/lib/talons/MagentoRoute/magentoRoute.gql.js +4 -2
- package/lib/talons/MagentoRoute/useMagentoRoute.js +39 -33
- package/lib/talons/MegaMenu/megaMenu.gql.js +10 -5
- package/lib/talons/MegaMenu/useMegaMenu.js +3 -5
- package/lib/talons/MegaMenu/useMegaMenuItem.js +5 -0
- package/lib/talons/MiniCart/ProductList/productListFragments.gql.js +11 -5
- package/lib/talons/MiniCart/miniCart.gql.js +2 -1
- package/lib/talons/MiniCart/useItem.js +3 -3
- package/lib/talons/MiniCart/useMiniCart.js +8 -7
- package/lib/talons/Navigation/navigation.gql.js +4 -3
- package/lib/talons/Navigation/useNavigation.js +1 -1
- package/lib/talons/Newsletter/newsletter.gql.js +24 -0
- package/lib/talons/Newsletter/useNewsletter.js +70 -0
- package/lib/talons/OrderHistoryPage/orderHistoryContext.gql.js +2 -1
- package/lib/talons/OrderHistoryPage/orderHistoryPage.gql.js +1 -1
- package/lib/talons/OrderHistoryPage/orderRow.gql.js +7 -3
- package/lib/talons/ProductFullDetail/CustomAttributes/AttributeType/useAttributeType.js +26 -0
- package/lib/talons/ProductFullDetail/productFullDetail.gql.ce.js +4 -3
- package/lib/talons/ProductFullDetail/productFullDetail.gql.ee.js +2 -1
- package/lib/talons/ProductFullDetail/useProductFullDetail.js +35 -3
- package/lib/talons/RootComponents/Category/category.gql.js +7 -4
- package/lib/talons/RootComponents/Category/categoryContent.gql.js +26 -7
- package/lib/talons/RootComponents/Category/categoryFragments.gql.js +5 -2
- package/lib/talons/RootComponents/Category/useCategory.js +8 -6
- package/lib/talons/RootComponents/Category/useCategoryContent.js +30 -3
- package/lib/talons/RootComponents/Category/useNoProductsFound.js +0 -1
- package/lib/talons/RootComponents/Product/product.gql.js +3 -1
- package/lib/talons/RootComponents/Product/productDetailFragment.gql.js +69 -10
- package/lib/talons/SearchPage/searchPage.gql.js +18 -2
- package/lib/talons/SearchPage/useSearchPage.js +25 -0
- package/lib/talons/SignIn/signIn.gql.js +4 -3
- package/lib/talons/SignIn/useSignIn.js +2 -4
- package/lib/talons/Wishlist/WishlistDialog/wishlistDialog.gql.js +3 -2
- package/lib/talons/WishlistPage/createWishlist.gql.js +2 -1
- package/lib/talons/WishlistPage/useWishlistItem.js +2 -2
- package/lib/talons/WishlistPage/wishlist.gql.js +2 -2
- package/lib/talons/WishlistPage/wishlistConfig.gql.ce.js +2 -1
- package/lib/talons/WishlistPage/wishlistConfig.gql.ee.js +2 -1
- package/lib/talons/WishlistPage/wishlistItemFragments.gql.js +5 -2
- package/lib/talons/WishlistPage/wishlistPage.gql.js +1 -1
- package/package.json +6 -6
- package/lib/Apollo/clearStore.js +0 -26
- package/lib/Apollo/deleteCacheEntry.js +0 -87
|
@@ -7,6 +7,7 @@ const GET_CONFIGURABLE_OPTIONS = gql`
|
|
|
7
7
|
products(filter: { sku: { eq: $sku } }) {
|
|
8
8
|
items {
|
|
9
9
|
id
|
|
10
|
+
uid
|
|
10
11
|
...ProductFormFragment
|
|
11
12
|
}
|
|
12
13
|
}
|
|
@@ -17,15 +18,17 @@ const GET_CONFIGURABLE_OPTIONS = gql`
|
|
|
17
18
|
const UPDATE_QUANTITY_MUTATION = gql`
|
|
18
19
|
mutation UpdateCartItemQuantity(
|
|
19
20
|
$cartId: String!
|
|
20
|
-
$cartItemId:
|
|
21
|
+
$cartItemId: ID!
|
|
21
22
|
$quantity: Float!
|
|
22
23
|
) {
|
|
23
24
|
updateCartItems(
|
|
24
25
|
input: {
|
|
25
26
|
cart_id: $cartId
|
|
26
|
-
cart_items: [
|
|
27
|
+
cart_items: [
|
|
28
|
+
{ cart_item_uid: $cartItemId, quantity: $quantity }
|
|
29
|
+
]
|
|
27
30
|
}
|
|
28
|
-
)
|
|
31
|
+
) {
|
|
29
32
|
cart {
|
|
30
33
|
id
|
|
31
34
|
...CartPageFragment
|
|
@@ -38,7 +41,7 @@ const UPDATE_QUANTITY_MUTATION = gql`
|
|
|
38
41
|
const UPDATE_CONFIGURABLE_OPTIONS_MUTATION = gql`
|
|
39
42
|
mutation UpdateConfigurableOptions(
|
|
40
43
|
$cartId: String!
|
|
41
|
-
$cartItemId:
|
|
44
|
+
$cartItemId: ID!
|
|
42
45
|
$parentSku: String!
|
|
43
46
|
$variantSku: String!
|
|
44
47
|
$quantity: Float!
|
|
@@ -53,15 +56,15 @@ const UPDATE_CONFIGURABLE_OPTIONS_MUTATION = gql`
|
|
|
53
56
|
}
|
|
54
57
|
]
|
|
55
58
|
}
|
|
56
|
-
)
|
|
59
|
+
) {
|
|
57
60
|
cart {
|
|
58
61
|
id
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
removeItemFromCart(
|
|
63
|
-
input: { cart_id: $cartId,
|
|
64
|
-
)
|
|
66
|
+
input: { cart_id: $cartId, cart_item_uid: $cartItemId }
|
|
67
|
+
) {
|
|
65
68
|
cart {
|
|
66
69
|
id
|
|
67
70
|
...CartPageFragment
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { gql } from '@apollo/client';
|
|
2
2
|
|
|
3
3
|
export const ProductFormFragment = gql`
|
|
4
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
4
5
|
fragment ProductFormFragment on ProductInterface {
|
|
5
|
-
|
|
6
|
+
uid
|
|
6
7
|
sku
|
|
8
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
7
9
|
... on ConfigurableProduct {
|
|
10
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
8
11
|
configurable_options {
|
|
9
12
|
attribute_code
|
|
10
13
|
attribute_id
|
|
11
|
-
|
|
14
|
+
uid
|
|
12
15
|
label
|
|
13
16
|
values {
|
|
14
17
|
default_label
|
|
@@ -29,8 +32,9 @@ export const ProductFormFragment = gql`
|
|
|
29
32
|
code
|
|
30
33
|
value_index
|
|
31
34
|
}
|
|
35
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
32
36
|
product {
|
|
33
|
-
|
|
37
|
+
uid
|
|
34
38
|
price {
|
|
35
39
|
regularPrice {
|
|
36
40
|
amount {
|
|
@@ -90,6 +90,7 @@ export const useProductForm = props => {
|
|
|
90
90
|
const handleOptionSelection = useCallback(
|
|
91
91
|
(optionId, selection) => {
|
|
92
92
|
const nextOptionSelections = new Map([...optionSelections]);
|
|
93
|
+
|
|
93
94
|
const initialSelection = cartItem.configurable_options.find(
|
|
94
95
|
option => option.id == optionId
|
|
95
96
|
);
|
|
@@ -156,7 +157,7 @@ export const useProductForm = props => {
|
|
|
156
157
|
await updateConfigurableOptions({
|
|
157
158
|
variables: {
|
|
158
159
|
cartId,
|
|
159
|
-
cartItemId: cartItem.
|
|
160
|
+
cartItemId: cartItem.uid,
|
|
160
161
|
parentSku: cartItem.product.sku,
|
|
161
162
|
variantSku: selectedVariant.product.sku,
|
|
162
163
|
quantity: formValues.quantity
|
|
@@ -168,7 +169,7 @@ export const useProductForm = props => {
|
|
|
168
169
|
await updateItemQuantity({
|
|
169
170
|
variables: {
|
|
170
171
|
cartId,
|
|
171
|
-
cartItemId: cartItem.
|
|
172
|
+
cartItemId: cartItem.uid,
|
|
172
173
|
quantity: formValues.quantity
|
|
173
174
|
}
|
|
174
175
|
});
|
|
@@ -2,8 +2,9 @@ import { gql } from '@apollo/client';
|
|
|
2
2
|
|
|
3
3
|
export const GET_STORE_CONFIG = gql`
|
|
4
4
|
query getStoreConfigForCartPage {
|
|
5
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
5
6
|
storeConfig {
|
|
6
|
-
|
|
7
|
+
store_code
|
|
7
8
|
product_url_suffix
|
|
8
9
|
configurable_thumbnail_source
|
|
9
10
|
}
|
|
@@ -3,8 +3,9 @@ import { ProductListingFragment } from './productListingFragments.gql';
|
|
|
3
3
|
|
|
4
4
|
export const GET_WISHLIST_CONFIG = gql`
|
|
5
5
|
query GetWishlistConfigForCartPageCE {
|
|
6
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
6
7
|
storeConfig {
|
|
7
|
-
|
|
8
|
+
store_code
|
|
8
9
|
magento_wishlist_general_is_enabled
|
|
9
10
|
}
|
|
10
11
|
}
|
|
@@ -3,8 +3,9 @@ import { ProductListingFragment } from './productListingFragments.gql';
|
|
|
3
3
|
|
|
4
4
|
export const GET_WISHLIST_CONFIG = gql`
|
|
5
5
|
query GetWishlistConfigForCartPageEE {
|
|
6
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
6
7
|
storeConfig {
|
|
7
|
-
|
|
8
|
+
store_code
|
|
8
9
|
magento_wishlist_general_is_enabled
|
|
9
10
|
enable_multiple_wishlists
|
|
10
11
|
}
|
|
@@ -3,10 +3,12 @@ import { gql } from '@apollo/client';
|
|
|
3
3
|
export const ProductListingFragment = gql`
|
|
4
4
|
fragment ProductListingFragment on Cart {
|
|
5
5
|
id
|
|
6
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
6
7
|
items {
|
|
7
|
-
|
|
8
|
+
uid
|
|
9
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
8
10
|
product {
|
|
9
|
-
|
|
11
|
+
uid
|
|
10
12
|
name
|
|
11
13
|
sku
|
|
12
14
|
url_key
|
|
@@ -17,13 +19,15 @@ export const ProductListingFragment = gql`
|
|
|
17
19
|
url
|
|
18
20
|
}
|
|
19
21
|
stock_status
|
|
22
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
20
23
|
... on ConfigurableProduct {
|
|
21
24
|
variants {
|
|
22
25
|
attributes {
|
|
23
26
|
uid
|
|
24
27
|
}
|
|
28
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
25
29
|
product {
|
|
26
|
-
|
|
30
|
+
uid
|
|
27
31
|
small_image {
|
|
28
32
|
url
|
|
29
33
|
}
|
|
@@ -38,12 +42,18 @@ export const ProductListingFragment = gql`
|
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
44
|
quantity
|
|
45
|
+
errors {
|
|
46
|
+
code
|
|
47
|
+
message
|
|
48
|
+
}
|
|
49
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
41
50
|
... on ConfigurableCartItem {
|
|
51
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
42
52
|
configurable_options {
|
|
43
53
|
id
|
|
44
|
-
|
|
54
|
+
configurable_product_option_uid
|
|
45
55
|
option_label
|
|
46
|
-
|
|
56
|
+
configurable_product_option_value_uid
|
|
47
57
|
value_label
|
|
48
58
|
}
|
|
49
59
|
}
|
|
@@ -107,13 +107,20 @@ export const useProduct = props => {
|
|
|
107
107
|
updateItemLoading
|
|
108
108
|
]);
|
|
109
109
|
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
if (item.errors) {
|
|
112
|
+
setDisplayError(true);
|
|
113
|
+
}
|
|
114
|
+
}, [item.errors]);
|
|
115
|
+
|
|
110
116
|
const derivedErrorMessage = useMemo(() => {
|
|
111
117
|
return (
|
|
112
118
|
(displayError &&
|
|
113
119
|
deriveErrorMessage([updateError, removeItemError])) ||
|
|
120
|
+
deriveErrorMessage([...(item.errors || [])]) ||
|
|
114
121
|
''
|
|
115
122
|
);
|
|
116
|
-
}, [displayError, removeItemError, updateError]);
|
|
123
|
+
}, [displayError, removeItemError, updateError, item.errors]);
|
|
117
124
|
|
|
118
125
|
const handleEditItem = useCallback(() => {
|
|
119
126
|
setActiveEditItem(item);
|
|
@@ -128,14 +135,14 @@ export const useProduct = props => {
|
|
|
128
135
|
await removeItemFromCart({
|
|
129
136
|
variables: {
|
|
130
137
|
cartId,
|
|
131
|
-
itemId: item.
|
|
138
|
+
itemId: item.uid
|
|
132
139
|
}
|
|
133
140
|
});
|
|
134
141
|
} catch (err) {
|
|
135
142
|
// Make sure any errors from the mutation are displayed.
|
|
136
143
|
setDisplayError(true);
|
|
137
144
|
}
|
|
138
|
-
}, [cartId, item.
|
|
145
|
+
}, [cartId, item.uid, removeItemFromCart]);
|
|
139
146
|
|
|
140
147
|
const handleUpdateItemQuantity = useCallback(
|
|
141
148
|
async quantity => {
|
|
@@ -143,7 +150,7 @@ export const useProduct = props => {
|
|
|
143
150
|
await updateItemQuantity({
|
|
144
151
|
variables: {
|
|
145
152
|
cartId,
|
|
146
|
-
itemId: item.
|
|
153
|
+
itemId: item.uid,
|
|
147
154
|
quantity
|
|
148
155
|
}
|
|
149
156
|
});
|
|
@@ -152,7 +159,7 @@ export const useProduct = props => {
|
|
|
152
159
|
setDisplayError(true);
|
|
153
160
|
}
|
|
154
161
|
},
|
|
155
|
-
[cartId, item.
|
|
162
|
+
[cartId, item.uid, updateItemQuantity]
|
|
156
163
|
);
|
|
157
164
|
|
|
158
165
|
useEffect(() => {
|
|
@@ -54,13 +54,14 @@ export const useProductListing = (props = {}) => {
|
|
|
54
54
|
}, [cartId, fetchProductListing]);
|
|
55
55
|
|
|
56
56
|
let items = [];
|
|
57
|
-
if (called && !
|
|
58
|
-
items = data
|
|
57
|
+
if (called && !loading) {
|
|
58
|
+
items = data?.cart?.items || [];
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
return {
|
|
62
62
|
activeEditItem,
|
|
63
63
|
isLoading: !!loading,
|
|
64
|
+
error,
|
|
64
65
|
items,
|
|
65
66
|
setActiveEditItem,
|
|
66
67
|
wishlistConfig
|
|
@@ -89,6 +90,7 @@ export const useProductListing = (props = {}) => {
|
|
|
89
90
|
*
|
|
90
91
|
* @property {Object} activeEditItem The product item currently being edited
|
|
91
92
|
* @property {boolean} isLoading True if the query to get the product listing is still in progress. False otherwise.
|
|
93
|
+
* @property {Error|null} error An array of graphql errors
|
|
92
94
|
* @property {Array<Object>} items A list of products in a cart
|
|
93
95
|
* @property {function} setActiveEditItem Function for setting the current item to edit
|
|
94
96
|
*
|
|
@@ -36,15 +36,16 @@ export const useCartPage = (props = {}) => {
|
|
|
36
36
|
getCartDetailsQuery,
|
|
37
37
|
{
|
|
38
38
|
fetchPolicy: 'cache-and-network',
|
|
39
|
-
nextFetchPolicy: 'cache-first'
|
|
39
|
+
nextFetchPolicy: 'cache-first',
|
|
40
|
+
errorPolicy: 'all'
|
|
40
41
|
}
|
|
41
42
|
);
|
|
42
43
|
|
|
43
|
-
const hasItems = !!
|
|
44
|
+
const hasItems = !!data?.cart?.total_quantity;
|
|
44
45
|
const shouldShowLoadingIndicator = called && loading && !hasItems;
|
|
45
46
|
|
|
46
47
|
const cartItems = useMemo(() => {
|
|
47
|
-
return
|
|
48
|
+
return data?.cart?.items || [];
|
|
48
49
|
}, [data]);
|
|
49
50
|
|
|
50
51
|
const onAddToWishlistSuccess = useCallback(successToastProps => {
|
|
@@ -1,31 +1,39 @@
|
|
|
1
|
+
/* Deprecated in PWA-12.1.0*/
|
|
2
|
+
|
|
1
3
|
import { gql } from '@apollo/client';
|
|
2
4
|
|
|
3
5
|
export const GET_STORE_CONFIG_DATA = gql`
|
|
4
6
|
query GetStoreConfigForCategoryList {
|
|
7
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
5
8
|
storeConfig {
|
|
6
|
-
|
|
9
|
+
store_code
|
|
7
10
|
category_url_suffix
|
|
8
11
|
}
|
|
9
12
|
}
|
|
10
13
|
`;
|
|
11
14
|
|
|
12
15
|
export const GET_CATEGORY_LIST = gql`
|
|
13
|
-
query GetCategoryList($id:
|
|
14
|
-
|
|
15
|
-
id
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
query GetCategoryList($id: String!) {
|
|
17
|
+
categories(filters: { category_uid: { in: [$id] } }) {
|
|
18
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
19
|
+
items {
|
|
20
|
+
uid
|
|
21
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
22
|
+
children {
|
|
23
|
+
uid
|
|
24
|
+
name
|
|
25
|
+
url_key
|
|
26
|
+
url_path
|
|
27
|
+
children_count
|
|
28
|
+
path
|
|
29
|
+
image
|
|
30
|
+
productImagePreview: products(pageSize: 1) {
|
|
31
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
32
|
+
items {
|
|
33
|
+
uid
|
|
34
|
+
small_image {
|
|
35
|
+
url
|
|
36
|
+
}
|
|
29
37
|
}
|
|
30
38
|
}
|
|
31
39
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* Deprecated in PWA-12.1.0*/
|
|
2
|
+
|
|
1
3
|
import { useQuery } from '@apollo/client';
|
|
2
4
|
|
|
3
5
|
import mergeOperations from '../../util/shallowMerge';
|
|
@@ -35,7 +37,10 @@ export const useCategoryList = props => {
|
|
|
35
37
|
|
|
36
38
|
return {
|
|
37
39
|
childCategories:
|
|
38
|
-
(data &&
|
|
40
|
+
(data &&
|
|
41
|
+
data.categories.items[0] &&
|
|
42
|
+
data.categories.items[0].children) ||
|
|
43
|
+
null,
|
|
39
44
|
storeConfig,
|
|
40
45
|
error,
|
|
41
46
|
loading
|
|
@@ -2,29 +2,35 @@ import { gql } from '@apollo/client';
|
|
|
2
2
|
|
|
3
3
|
export const GET_CATEGORY_URL_SUFFIX = gql`
|
|
4
4
|
query GetStoreConfigForCategoryTree {
|
|
5
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
5
6
|
storeConfig {
|
|
6
|
-
|
|
7
|
+
store_code
|
|
7
8
|
category_url_suffix
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
11
|
`;
|
|
11
12
|
|
|
12
13
|
export const GET_NAVIGATION_MENU = gql`
|
|
13
|
-
query GetNavigationMenu($id:
|
|
14
|
-
|
|
15
|
-
id
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
query GetNavigationMenu($id: String!) {
|
|
15
|
+
categories(filters: { category_uid: { in: [$id] } }) {
|
|
16
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
17
|
+
items {
|
|
18
|
+
uid
|
|
19
|
+
name
|
|
20
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
21
|
+
children {
|
|
22
|
+
children_count
|
|
23
|
+
uid
|
|
24
|
+
include_in_menu
|
|
25
|
+
name
|
|
26
|
+
position
|
|
27
|
+
url_path
|
|
28
|
+
url_suffix
|
|
29
|
+
}
|
|
18
30
|
children_count
|
|
19
|
-
id
|
|
20
31
|
include_in_menu
|
|
21
|
-
name
|
|
22
|
-
position
|
|
23
32
|
url_path
|
|
24
|
-
url_suffix
|
|
25
33
|
}
|
|
26
|
-
include_in_menu
|
|
27
|
-
url_path
|
|
28
34
|
}
|
|
29
35
|
}
|
|
30
36
|
`;
|
|
@@ -12,7 +12,7 @@ import { useCallback } from 'react';
|
|
|
12
12
|
*/
|
|
13
13
|
export const useCategoryBranch = props => {
|
|
14
14
|
const { category, setCategoryId } = props;
|
|
15
|
-
const { id, include_in_menu } = category;
|
|
15
|
+
const { uid: id, include_in_menu } = category;
|
|
16
16
|
|
|
17
17
|
// `include_in_menu` is undefined when Magento <= 2.3.1
|
|
18
18
|
const exclude = include_in_menu === 0;
|
|
@@ -54,12 +54,12 @@ export const useCategoryTree = props => {
|
|
|
54
54
|
|
|
55
55
|
// update redux with fetched categories
|
|
56
56
|
useEffect(() => {
|
|
57
|
-
if (data && data.
|
|
58
|
-
updateCategories(data.
|
|
57
|
+
if (data && data.categories.items[0]) {
|
|
58
|
+
updateCategories(data.categories.items[0]);
|
|
59
59
|
}
|
|
60
60
|
}, [data, updateCategories]);
|
|
61
61
|
|
|
62
|
-
const rootCategory = data && data.
|
|
62
|
+
const rootCategory = data && data.categories.items[0];
|
|
63
63
|
|
|
64
64
|
const { children = [] } = rootCategory || {};
|
|
65
65
|
|
|
@@ -72,7 +72,7 @@ export const useCategoryTree = props => {
|
|
|
72
72
|
rootCategory.include_in_menu &&
|
|
73
73
|
rootCategory.url_path
|
|
74
74
|
) {
|
|
75
|
-
childCategories.set(rootCategory.
|
|
75
|
+
childCategories.set(rootCategory.uid, {
|
|
76
76
|
category: rootCategory,
|
|
77
77
|
isLeaf: true
|
|
78
78
|
});
|
|
@@ -81,7 +81,7 @@ export const useCategoryTree = props => {
|
|
|
81
81
|
children.map(category => {
|
|
82
82
|
if (category.include_in_menu) {
|
|
83
83
|
const isLeaf = !parseInt(category.children_count);
|
|
84
|
-
childCategories.set(category.
|
|
84
|
+
childCategories.set(category.uid, { category, isLeaf });
|
|
85
85
|
}
|
|
86
86
|
});
|
|
87
87
|
|
|
@@ -6,8 +6,8 @@ import { ShippingInformationFragment } from '../ShippingInformation/shippingInfo
|
|
|
6
6
|
|
|
7
7
|
export const GET_CUSTOMER_ADDRESSES = gql`
|
|
8
8
|
query GetCustomerAddresses {
|
|
9
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
9
10
|
customer {
|
|
10
|
-
id
|
|
11
11
|
addresses {
|
|
12
12
|
id
|
|
13
13
|
...CustomerAddressFragment
|
|
@@ -18,16 +18,16 @@ export default {
|
|
|
18
18
|
quantity: 3,
|
|
19
19
|
configurable_options: [
|
|
20
20
|
{
|
|
21
|
-
|
|
21
|
+
configurable_product_option_uid: 179,
|
|
22
22
|
option_label: 'Fashion Color',
|
|
23
|
-
|
|
23
|
+
configurable_product_option_value_uid: 18,
|
|
24
24
|
value_label: 'Peach',
|
|
25
25
|
__typename: 'SelectedConfigurableOption'
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
|
-
|
|
28
|
+
configurable_product_option_uid: 182,
|
|
29
29
|
option_label: 'Fashion Size',
|
|
30
|
-
|
|
30
|
+
configurable_product_option_value_uid: 27,
|
|
31
31
|
value_label: 'M',
|
|
32
32
|
__typename: 'SelectedConfigurableOption'
|
|
33
33
|
}
|
|
@@ -49,16 +49,16 @@ export default {
|
|
|
49
49
|
quantity: 1,
|
|
50
50
|
configurable_options: [
|
|
51
51
|
{
|
|
52
|
-
|
|
52
|
+
configurable_product_option_uid: 179,
|
|
53
53
|
option_label: 'Fashion Color',
|
|
54
|
-
|
|
54
|
+
configurable_product_option_value_uid: 21,
|
|
55
55
|
value_label: 'Rain',
|
|
56
56
|
__typename: 'SelectedConfigurableOption'
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
|
-
|
|
59
|
+
configurable_product_option_uid: 182,
|
|
60
60
|
option_label: 'Fashion Size',
|
|
61
|
-
|
|
61
|
+
configurable_product_option_value_uid: 29,
|
|
62
62
|
value_label: 'XS',
|
|
63
63
|
__typename: 'SelectedConfigurableOption'
|
|
64
64
|
}
|
|
@@ -80,16 +80,16 @@ export default {
|
|
|
80
80
|
quantity: 3,
|
|
81
81
|
configurable_options: [
|
|
82
82
|
{
|
|
83
|
-
|
|
83
|
+
configurable_product_option_uid: 179,
|
|
84
84
|
option_label: 'Fashion Color',
|
|
85
|
-
|
|
85
|
+
configurable_product_option_value_uid: 20,
|
|
86
86
|
value_label: 'Lilac',
|
|
87
87
|
__typename: 'SelectedConfigurableOption'
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
|
-
|
|
90
|
+
configurable_product_option_uid: 182,
|
|
91
91
|
option_label: 'Fashion Size',
|
|
92
|
-
|
|
92
|
+
configurable_product_option_value_uid: 26,
|
|
93
93
|
value_label: 'L',
|
|
94
94
|
__typename: 'SelectedConfigurableOption'
|
|
95
95
|
}
|
|
@@ -4,8 +4,9 @@ import { ItemsReviewFragment } from './itemsReviewFragments.gql';
|
|
|
4
4
|
|
|
5
5
|
export const GET_CONFIGURABLE_THUMBNAIL_SOURCE = gql`
|
|
6
6
|
query getConfigurableThumbnailSource {
|
|
7
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
7
8
|
storeConfig {
|
|
8
|
-
|
|
9
|
+
store_code
|
|
9
10
|
configurable_thumbnail_source
|
|
10
11
|
}
|
|
11
12
|
}
|
|
@@ -4,21 +4,25 @@ export const ItemsReviewFragment = gql`
|
|
|
4
4
|
fragment ItemsReviewFragment on Cart {
|
|
5
5
|
id
|
|
6
6
|
total_quantity
|
|
7
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
7
8
|
items {
|
|
8
|
-
|
|
9
|
+
uid
|
|
10
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
9
11
|
product {
|
|
10
|
-
|
|
12
|
+
uid
|
|
11
13
|
name
|
|
12
14
|
thumbnail {
|
|
13
15
|
url
|
|
14
16
|
}
|
|
17
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
15
18
|
... on ConfigurableProduct {
|
|
16
19
|
variants {
|
|
17
20
|
attributes {
|
|
18
21
|
uid
|
|
19
22
|
}
|
|
23
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
20
24
|
product {
|
|
21
|
-
|
|
25
|
+
uid
|
|
22
26
|
thumbnail {
|
|
23
27
|
url
|
|
24
28
|
}
|
|
@@ -27,11 +31,13 @@ export const ItemsReviewFragment = gql`
|
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
33
|
quantity
|
|
34
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
30
35
|
... on ConfigurableCartItem {
|
|
36
|
+
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
31
37
|
configurable_options {
|
|
32
|
-
|
|
38
|
+
configurable_product_option_uid
|
|
33
39
|
option_label
|
|
34
|
-
|
|
40
|
+
configurable_product_option_value_uid
|
|
35
41
|
value_label
|
|
36
42
|
}
|
|
37
43
|
}
|