@magento/peregrine 13.0.1-beta.3 → 13.1.1-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/talons/CartPage/GiftCards/useGiftCards.js +17 -0
- package/lib/talons/CartPage/PriceAdjustments/CouponCode/useCouponCode.js +19 -0
- package/lib/talons/CartPage/PriceAdjustments/ShippingMethods/useShippingForm.js +10 -0
- package/lib/talons/CartPage/PriceAdjustments/ShippingMethods/useShippingMethods.js +10 -1
- package/lib/talons/CheckoutPage/ItemsReview/__fixtures__/cartItems.js +3 -3
- package/lib/talons/CheckoutPage/PaymentInformation/usePaymentMethods.js +14 -7
- package/lib/talons/FilterModal/helpers.js +1 -1
- package/lib/talons/Link/useLink.js +1 -3
- package/lib/talons/MagentoRoute/useMagentoRoute.js +10 -0
- package/lib/talons/SignIn/useSignIn.js +9 -0
- package/package.json +1 -1
|
@@ -109,6 +109,14 @@ export const useGiftCards = props => {
|
|
|
109
109
|
});
|
|
110
110
|
}, [formApi, checkCardBalance]);
|
|
111
111
|
|
|
112
|
+
const checkGiftCardBalanceKeyPress = useCallback(() => {
|
|
113
|
+
event => {
|
|
114
|
+
if (event.key === 'Enter') {
|
|
115
|
+
checkGiftCardBalance();
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}, [checkGiftCardBalance]);
|
|
119
|
+
|
|
112
120
|
const removeGiftCard = useCallback(
|
|
113
121
|
async giftCardCode => {
|
|
114
122
|
setMostRecentAction(actions.REMOVE);
|
|
@@ -148,6 +156,13 @@ export const useGiftCards = props => {
|
|
|
148
156
|
removeCardLoading,
|
|
149
157
|
setIsCartUpdating
|
|
150
158
|
]);
|
|
159
|
+
const handleEnterKeyPress = useCallback(() => {
|
|
160
|
+
event => {
|
|
161
|
+
if (event.key === 'Enter') {
|
|
162
|
+
applyGiftCard();
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
}, [applyGiftCard]);
|
|
151
166
|
|
|
152
167
|
const shouldDisplayCardBalance =
|
|
153
168
|
mostRecentAction === actions.CHECK_BALANCE &&
|
|
@@ -163,12 +178,14 @@ export const useGiftCards = props => {
|
|
|
163
178
|
checkBalanceData:
|
|
164
179
|
balanceResult.data && balanceResult.data.giftCardAccount,
|
|
165
180
|
checkGiftCardBalance,
|
|
181
|
+
checkGiftCardBalanceKeyPress,
|
|
166
182
|
errorLoadingGiftCards: Boolean(appliedCardsResult.error),
|
|
167
183
|
errorRemovingCard: Boolean(removeCardResult.error),
|
|
168
184
|
giftCardsData:
|
|
169
185
|
(appliedCardsResult.data &&
|
|
170
186
|
appliedCardsResult.data.cart.applied_gift_cards) ||
|
|
171
187
|
[],
|
|
188
|
+
handleEnterKeyPress,
|
|
172
189
|
isLoadingGiftCards: appliedCardsResult.loading,
|
|
173
190
|
isApplyingCard: applyCardLoading,
|
|
174
191
|
isCheckingBalance: balanceResult.loading,
|
|
@@ -78,6 +78,13 @@ export const useCouponCode = props => {
|
|
|
78
78
|
},
|
|
79
79
|
[applyCoupon, cartId]
|
|
80
80
|
);
|
|
81
|
+
const handleApplyCouponOnEnter = useCallback(() => {
|
|
82
|
+
event => {
|
|
83
|
+
if (event.key === 'Enter') {
|
|
84
|
+
handleApplyCoupon();
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}, [handleApplyCoupon]);
|
|
81
88
|
|
|
82
89
|
const handleRemoveCoupon = useCallback(
|
|
83
90
|
async couponCode => {
|
|
@@ -95,6 +102,14 @@ export const useCouponCode = props => {
|
|
|
95
102
|
[cartId, removeCoupon]
|
|
96
103
|
);
|
|
97
104
|
|
|
105
|
+
const handleRemoveCouponOnEnter = useCallback(() => {
|
|
106
|
+
event => {
|
|
107
|
+
if (event.key === 'Enter') {
|
|
108
|
+
handleRemoveCoupon();
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}, [handleRemoveCoupon]);
|
|
112
|
+
|
|
98
113
|
useEffect(() => {
|
|
99
114
|
if (applyCouponCalled || removeCouponCalled) {
|
|
100
115
|
// If a coupon mutation is in flight, tell the cart.
|
|
@@ -124,7 +139,9 @@ export const useCouponCode = props => {
|
|
|
124
139
|
data,
|
|
125
140
|
errors,
|
|
126
141
|
handleApplyCoupon,
|
|
142
|
+
handleApplyCouponOnEnter,
|
|
127
143
|
handleRemoveCoupon,
|
|
144
|
+
handleRemoveCouponOnEnter,
|
|
128
145
|
removingCoupon
|
|
129
146
|
};
|
|
130
147
|
};
|
|
@@ -167,6 +184,8 @@ export const useCouponCode = props => {
|
|
|
167
184
|
* @property {String} errorMessage If GraphQL error occurs, this value is set.
|
|
168
185
|
* @property {Object} fetchError The error data object returned by a GraphQL query.
|
|
169
186
|
* @property {function} handleApplyCoupon Function to call for handling the application of a coupon code to a cart.
|
|
187
|
+
* @property {function} handleApplyCouponOnEnter Function to call for handling the application of a coupon code to a cart on enter key Press.
|
|
170
188
|
* @property {function} handleRemoveCoupon Function to call for handling the removal of a coupon code from a cart
|
|
189
|
+
* @property {function} handleRemoveCouponOnEnter Function to call for handling the removal of a coupon code from a cart on enter key press.
|
|
171
190
|
* @property {boolean} removingCoupon True if a coupon code is currently being removed. False otherwise.
|
|
172
191
|
*/
|
|
@@ -137,6 +137,14 @@ export const useShippingForm = props => {
|
|
|
137
137
|
[cartId, setShippingAddress]
|
|
138
138
|
);
|
|
139
139
|
|
|
140
|
+
const handleOnSubmitKeyPress = useCallback(() => {
|
|
141
|
+
event => {
|
|
142
|
+
if (event.key === 'Enter') {
|
|
143
|
+
handleOnSubmit();
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}, [handleOnSubmit]);
|
|
147
|
+
|
|
140
148
|
const errors = useMemo(
|
|
141
149
|
() =>
|
|
142
150
|
new Map([
|
|
@@ -149,6 +157,7 @@ export const useShippingForm = props => {
|
|
|
149
157
|
errors,
|
|
150
158
|
handleOnSubmit,
|
|
151
159
|
handleZipChange,
|
|
160
|
+
handleOnSubmitKeyPress,
|
|
152
161
|
isSetShippingLoading
|
|
153
162
|
};
|
|
154
163
|
};
|
|
@@ -198,6 +207,7 @@ export const useShippingForm = props => {
|
|
|
198
207
|
*
|
|
199
208
|
* @property {Array<Error>} formErrors A list of form errors
|
|
200
209
|
* @property {function} handleOnSubmit Callback function to handle form submissions
|
|
210
|
+
* @property {function} handleOnSubmitKeyPress Callback function to handle form submissions on enter key
|
|
201
211
|
* @property {function} handleZipChange Callback function to handle a zip code change
|
|
202
212
|
* @property {boolean} isSetShippingLoading True if the cart shipping information is being set. False otherwise.
|
|
203
213
|
*/
|
|
@@ -39,6 +39,13 @@ export const useShippingMethods = (props = {}) => {
|
|
|
39
39
|
|
|
40
40
|
const [isShowingForm, setIsShowingForm] = useState(false);
|
|
41
41
|
const showForm = useCallback(() => setIsShowingForm(true), []);
|
|
42
|
+
const showFormOnEnter = useCallback(() => {
|
|
43
|
+
event => {
|
|
44
|
+
if (event.key === 'Enter') {
|
|
45
|
+
showForm();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}, [showForm]);
|
|
42
49
|
|
|
43
50
|
useEffect(() => {
|
|
44
51
|
if (data && data.cart.shipping_addresses.length) {
|
|
@@ -92,7 +99,8 @@ export const useShippingMethods = (props = {}) => {
|
|
|
92
99
|
selectedShippingFields,
|
|
93
100
|
selectedShippingMethod,
|
|
94
101
|
shippingMethods: formattedShippingMethods,
|
|
95
|
-
showForm
|
|
102
|
+
showForm,
|
|
103
|
+
showFormOnEnter
|
|
96
104
|
};
|
|
97
105
|
};
|
|
98
106
|
|
|
@@ -123,4 +131,5 @@ export const useShippingMethods = (props = {}) => {
|
|
|
123
131
|
* @property {String} selectedShippingMethod A serialized string of <inlineCode>${carrier-code}\|${method-code}</inlineCode>, eg. <inlineCode>usps\|priority</inlineCode>.
|
|
124
132
|
* @property {Array<Object>} shippingMethods A list of available shipping methods based on the primary shipping address
|
|
125
133
|
* @property {function} showForm A function that sets the `isShowingForm` value to true.
|
|
134
|
+
* @property {function} showFormOnEnter A function that sets the `isShowingForm` value to true.
|
|
126
135
|
*/
|
|
@@ -10,7 +10,7 @@ export default {
|
|
|
10
10
|
name: 'Jillian Top',
|
|
11
11
|
thumbnail: {
|
|
12
12
|
url:
|
|
13
|
-
'https://master-7rqtwti-
|
|
13
|
+
'https://master-7rqtwti-c5v7sxvquxwl4.eu-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/t/vt12-kh_main_2.jpg',
|
|
14
14
|
__typename: 'ProductImage'
|
|
15
15
|
},
|
|
16
16
|
__typename: 'ConfigurableProduct'
|
|
@@ -41,7 +41,7 @@ export default {
|
|
|
41
41
|
name: 'Juno Sweater',
|
|
42
42
|
thumbnail: {
|
|
43
43
|
url:
|
|
44
|
-
'https://master-7rqtwti-
|
|
44
|
+
'https://master-7rqtwti-c5v7sxvquxwl4.eu-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/s/vsw02-pe_main_2.jpg',
|
|
45
45
|
__typename: 'ProductImage'
|
|
46
46
|
},
|
|
47
47
|
__typename: 'ConfigurableProduct'
|
|
@@ -72,7 +72,7 @@ export default {
|
|
|
72
72
|
name: 'Angelina Tank Dress',
|
|
73
73
|
thumbnail: {
|
|
74
74
|
url:
|
|
75
|
-
'https://master-7rqtwti-
|
|
75
|
+
'https://master-7rqtwti-c5v7sxvquxwl4.eu-4.magentosite.cloud/media/catalog/product/cache/d3ba9f7bcd3b0724e976dc5144b29c7d/v/d/vd01-ll_main_2.jpg',
|
|
76
76
|
__typename: 'ProductImage'
|
|
77
77
|
},
|
|
78
78
|
__typename: 'ConfigurableProduct'
|
|
@@ -46,16 +46,23 @@ export const usePaymentMethods = props => {
|
|
|
46
46
|
element => {
|
|
47
47
|
const value = element.target.value;
|
|
48
48
|
|
|
49
|
+
const paymentMethodData =
|
|
50
|
+
value == 'braintree'
|
|
51
|
+
? {
|
|
52
|
+
code: value,
|
|
53
|
+
braintree: {
|
|
54
|
+
payment_method_nonce: value,
|
|
55
|
+
is_active_payment_token_enabler: false
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
: {
|
|
59
|
+
code: value
|
|
60
|
+
};
|
|
61
|
+
|
|
49
62
|
setPaymentMethod({
|
|
50
63
|
variables: {
|
|
51
64
|
cartId,
|
|
52
|
-
paymentMethod:
|
|
53
|
-
code: value,
|
|
54
|
-
braintree: {
|
|
55
|
-
payment_method_nonce: value,
|
|
56
|
-
is_active_payment_token_enabler: false
|
|
57
|
-
}
|
|
58
|
-
}
|
|
65
|
+
paymentMethod: paymentMethodData
|
|
59
66
|
}
|
|
60
67
|
});
|
|
61
68
|
},
|
|
@@ -143,7 +143,7 @@ export const stripHtml = html => html.replace(/(<([^>]+)>)/gi, '');
|
|
|
143
143
|
|
|
144
144
|
/** GetFilterInput helpers below. */
|
|
145
145
|
const getValueFromFilterString = keyValueString =>
|
|
146
|
-
keyValueString.split(DELIMITER)
|
|
146
|
+
keyValueString.split(DELIMITER).pop();
|
|
147
147
|
|
|
148
148
|
/**
|
|
149
149
|
* Converts a set of values to a range filter
|
|
@@ -8,9 +8,7 @@ import DEFAULT_OPERATIONS from '../MagentoRoute/magentoRoute.gql';
|
|
|
8
8
|
export const useLink = (props, passedOperations = {}) => {
|
|
9
9
|
const { innerRef: originalRef, to } = props;
|
|
10
10
|
const shouldPrefetch = props.prefetchType || props.shouldPrefetch;
|
|
11
|
-
const operations =
|
|
12
|
-
? mergeOperations(DEFAULT_OPERATIONS, passedOperations)
|
|
13
|
-
: {};
|
|
11
|
+
const operations = mergeOperations(DEFAULT_OPERATIONS, passedOperations);
|
|
14
12
|
|
|
15
13
|
const intersectionObserver = useIntersectionObserver();
|
|
16
14
|
const { resolveUrlQuery } = operations;
|
|
@@ -48,6 +48,16 @@ export const useMagentoRoute = (props = {}) => {
|
|
|
48
48
|
const { data, error, loading } = queryResult;
|
|
49
49
|
const { route } = data || {};
|
|
50
50
|
|
|
51
|
+
// redirect to external url
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (route) {
|
|
54
|
+
const external_URL = route.relative_url;
|
|
55
|
+
if (external_URL && external_URL.startsWith('http')) {
|
|
56
|
+
window.location.replace(external_URL);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}, [route]);
|
|
60
|
+
|
|
51
61
|
useEffect(() => {
|
|
52
62
|
if (initialized.current || !getInlinedPageData()) {
|
|
53
63
|
runQuery({
|
|
@@ -156,6 +156,14 @@ export const useSignIn = props => {
|
|
|
156
156
|
showForgotPassword();
|
|
157
157
|
}, [setDefaultUsername, showForgotPassword]);
|
|
158
158
|
|
|
159
|
+
const forgotPasswordHandleEnterKeyPress = useCallback(() => {
|
|
160
|
+
event => {
|
|
161
|
+
if (event.key === 'Enter') {
|
|
162
|
+
handleForgotPassword();
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
}, [handleForgotPassword]);
|
|
166
|
+
|
|
159
167
|
const handleCreateAccount = useCallback(() => {
|
|
160
168
|
const { current: formApi } = formApiRef;
|
|
161
169
|
|
|
@@ -197,6 +205,7 @@ export const useSignIn = props => {
|
|
|
197
205
|
handleEnterKeyPress,
|
|
198
206
|
signinHandleEnterKeyPress,
|
|
199
207
|
handleForgotPassword,
|
|
208
|
+
forgotPasswordHandleEnterKeyPress,
|
|
200
209
|
handleSubmit,
|
|
201
210
|
isBusy: isGettingDetails || isSigningIn || recaptchaLoading,
|
|
202
211
|
setFormApi,
|