@sonic-equipment/ui 258.0.1 → 258.0.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.
package/dist/index.js CHANGED
@@ -237,7 +237,7 @@ export { CheckoutPageSectionHeader } from './pages/checkout/layouts/checkout-pag
237
237
  export { CheckoutPageSectionLink } from './pages/checkout/layouts/checkout-page-layout/components/checkout-page-section-link.js';
238
238
  export { OrderConfirmationPage } from './pages/checkout/order-confirmation-page/order-confirmation-page.js';
239
239
  export { OrderConfirmationPageContent } from './pages/checkout/order-confirmation-page/order-confirmation-page-content.js';
240
- export { AdyenPayment, getAdyenQueryParams } from './pages/checkout/payment-page/components/adyen-payment.js';
240
+ export { AdyenPayment, getAdyenQueryParams, removeAdyenQueryParamsFromUrl } from './pages/checkout/payment-page/components/adyen-payment.js';
241
241
  export { Payment } from './pages/checkout/payment-page/components/payment.js';
242
242
  export { useGetAdyenRedirectResult } from './pages/checkout/payment-page/hooks/use-get-adyen-redirect-result.js';
243
243
  export { useHasReturnedFromAdyen } from './pages/checkout/payment-page/hooks/use-has-returned-from-adyen.js';
@@ -27,4 +27,5 @@ export declare function getAdyenQueryParams(): {
27
27
  customerId: string | undefined;
28
28
  redirectResult: string | undefined;
29
29
  };
30
+ export declare function removeAdyenQueryParamsFromUrl(): void;
30
31
  export {};
@@ -105,6 +105,8 @@ function AdyenPayment({ amount, cartId, countryCode, currencyCode, customerId, d
105
105
  const dropIn = checkout.create('dropin');
106
106
  if (redirectResult) {
107
107
  checkout.submitDetails({ details: { redirectResult } });
108
+ removeAdyenQueryParamsFromUrl();
109
+ queryStringParams.current = {};
108
110
  }
109
111
  if (dropinRef.current)
110
112
  dropinRef.current.unmount();
@@ -176,6 +178,20 @@ async function handlePaymentResponse(result, onSubmit, onError) {
176
178
  onError(error, result);
177
179
  }
178
180
  }
181
+ function removeAdyenQueryParamsFromUrl() {
182
+ if (typeof window === 'undefined')
183
+ return;
184
+ try {
185
+ const url = new URL(window.location.href);
186
+ url.searchParams.delete('amount');
187
+ url.searchParams.delete('customerId');
188
+ url.searchParams.delete('redirectResult');
189
+ window.history.replaceState(null, '', url.toString());
190
+ }
191
+ catch (error) {
192
+ logger.error(error);
193
+ }
194
+ }
179
195
  function handleRedirectPaymentAction(adyenPaymentResult) {
180
196
  if (typeof window === 'undefined' || typeof document === 'undefined')
181
197
  return;
@@ -198,4 +214,4 @@ function handleRedirectPaymentAction(adyenPaymentResult) {
198
214
  }
199
215
  }
200
216
 
201
- export { AdyenPayment, getAdyenQueryParams };
217
+ export { AdyenPayment, getAdyenQueryParams, removeAdyenQueryParamsFromUrl };
@@ -22,23 +22,9 @@ import { useDataLayer } from '../../../../shared/ga/use-data-layer.js';
22
22
  import { getCurrencyCodeBySymbol } from '../../../../shared/model/currency.js';
23
23
  import { isProductionEnvironment } from '../../../../shared/utils/environment.js';
24
24
  import { BillingAndInvoiceInformation } from '../../components/billing-and-invoice-information.js';
25
- import { AdyenPayment } from './adyen-payment.js';
25
+ import { removeAdyenQueryParamsFromUrl, AdyenPayment } from './adyen-payment.js';
26
26
  import styles from './payment.module.css.js';
27
27
 
28
- function removeAdyenQueryParamsFromUrl() {
29
- if (typeof window === 'undefined')
30
- return;
31
- try {
32
- const url = new URL(window.location.href);
33
- url.searchParams.delete('amount');
34
- url.searchParams.delete('customerId');
35
- url.searchParams.delete('redirectResult');
36
- window.history.replaceState(null, '', url.toString());
37
- }
38
- catch (error) {
39
- logger.error(error);
40
- }
41
- }
42
28
  function Payment({ atp, cart: _cart, form, isProcessing, onError: _onError, onPaymentComplete, onProcessing, }) {
43
29
  const { createEcommerceEvent, dataLayer } = useDataLayer();
44
30
  const { mutate: patchCart } = usePatchCart();
@@ -167,6 +153,7 @@ function Payment({ atp, cart: _cart, form, isProcessing, onError: _onError, onPa
167
153
  catch (error) {
168
154
  logger.error(error);
169
155
  invalidateCurrentCart();
156
+ onProcessing(false);
170
157
  }
171
158
  finally {
172
159
  onProcessing(false);
@@ -189,6 +176,7 @@ function Payment({ atp, cart: _cart, form, isProcessing, onError: _onError, onPa
189
176
  logger.error(error);
190
177
  setPaymentError(error);
191
178
  invalidateCurrentCart();
179
+ onProcessing(false);
192
180
  }
193
181
  finally {
194
182
  onProcessing(false);
@@ -221,6 +209,7 @@ function Payment({ atp, cart: _cart, form, isProcessing, onError: _onError, onPa
221
209
  }
222
210
  catch (error) {
223
211
  logger.error(error);
212
+ onProcessing(false);
224
213
  setAPIError(error);
225
214
  }
226
215
  finally {
@@ -229,10 +218,10 @@ function Payment({ atp, cart: _cart, form, isProcessing, onError: _onError, onPa
229
218
  }
230
219
  }, [onPaymentComplete, onPlaceOrderCompleted, onProcessing, placeOrder]);
231
220
  const onError = useCallback((error, result) => {
232
- onProcessing(false);
233
221
  invalidateAdyen();
234
222
  setPaymentError(error);
235
223
  logger.error(error);
224
+ onProcessing(false);
236
225
  _onError?.(error, result);
237
226
  }, [_onError, invalidateAdyen, onProcessing]);
238
227
  return (jsxs(Form, { className: styles['payment-form'], "data-test-selector": "paymentForm", id: form, onSubmit: e => {
@@ -31,7 +31,7 @@ function PaymentPageContent({ atp, cart, formId, hasAtp, isProcessing, onPayment
31
31
  ], "data-test-selector": "paymentPage", title: t('Review and payment'), children: jsxs(CheckoutPageLayout, { actions: {
32
32
  primary: (jsx(Button, { withArrow: true, "data-test-selector": "checkoutReviewAndSubmit_placeOrder", form: formId, isDisabled: isProcessing, isLoading: isProcessing ? jsx(FormattedMessage, { id: "Processing" }) : false, type: "submit", children: cart.paymentMethod?.name === 'PBI' ? (jsx(FormattedMessage, { id: "Finalize order" })) : (jsx(FormattedMessage, { id: "Finalize payment" })) })),
33
33
  }, mobileSummary: jsx(CartTotalsSummary, { currencyCode: currencyCode, totalAmount: cart.orderGrandTotal }), overview: jsx(CartTotals, { currencyCode: currencyCode, deliveryDate: hasAtp ? undefined : cart.requestedDeliveryDate, fulfillmentMethod: cart.fulfillmentMethod, isPayByInvoice: (cart.paymentOptions?.paymentMethods?.length || 1) <= 1 &&
34
- cart.paymentMethod?.name === 'PBI', shippingCost: cart.shippingAndHandling, subtotal: cart.orderSubTotal, tax: cart.totalTax, total: cart.orderGrandTotal, vatPercentage: cart.cartLines?.[0]?.pricing?.vatRate || 0 }), children: [jsx(CheckoutPageSection, { hasBorder: false, title: jsx(FormattedMessage, { id: "Payment" }), children: jsx(CheckoutPageSectionContent, { children: jsx(Payment, { atp: atp, cart: cart, form: formId, isProcessing: isProcessing, onPaymentComplete: onPaymentComplete, onProcessing: setIsProcessing }) }) }), jsx(CheckoutPageSection, { hasBorder: false, title: jsx(FormattedMessage, { id: "Order" }), children: jsx(CheckoutPageSectionContent, { stretch: true, children: jsx(OrderLineList, { children: cart.cartLines?.map(cartLine => (jsx(OrderLineCard, { deliveryDate: cartLine.atp?.date ?? null, href: cartLine.productUri, image: {
34
+ cart.paymentMethod?.name === 'PBI', shippingCost: cart.shippingAndHandling, subtotal: cart.orderSubTotal, tax: cart.totalTax, total: cart.orderGrandTotal, vatPercentage: cart.cartLines?.[0]?.pricing?.vatRate || 0 }), children: [jsx(CheckoutPageSection, { hasBorder: false, title: jsx(FormattedMessage, { id: "Payment" }), children: jsx(CheckoutPageSectionContent, { children: jsx(Payment, { atp: atp, cart: cart, form: formId, isProcessing: isProcessing, onError: () => setIsProcessing(false), onPaymentComplete: onPaymentComplete, onProcessing: setIsProcessing }) }) }), jsx(CheckoutPageSection, { hasBorder: false, title: jsx(FormattedMessage, { id: "Order" }), children: jsx(CheckoutPageSectionContent, { stretch: true, children: jsx(OrderLineList, { children: cart.cartLines?.map(cartLine => (jsx(OrderLineCard, { deliveryDate: cartLine.atp?.date ?? null, href: cartLine.productUri, image: {
35
35
  fit: 'contain',
36
36
  image: {
37
37
  '1': cartLine.smallImagePath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "258.0.1",
3
+ "version": "258.0.3",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {