@sonic-equipment/ui 259.0.5 → 259.0.6
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.
|
@@ -11,8 +11,6 @@ import { CheckoutPageLayout } from '../layouts/checkout-page-layout/checkout-pag
|
|
|
11
11
|
import { Page } from '../../components/page/page.js';
|
|
12
12
|
import { ErrorPage } from '../../error-page/error-page.js';
|
|
13
13
|
import { LoadingPage } from '../../loading-page/loading-page.js';
|
|
14
|
-
import { useSaveCartForLater } from '../../../shared/api/bff/hooks/cart/use-save-cart-for-later.js';
|
|
15
|
-
import { useIsAuthenticated } from '../../../shared/api/storefront/hooks/authentication/use-is-authenticated.js';
|
|
16
14
|
import { useDeleteCartLineById } from '../../../shared/api/storefront/hooks/cart/use-delete-cart-line-by-id.js';
|
|
17
15
|
import { useDeleteCurrentCart } from '../../../shared/api/storefront/hooks/cart/use-delete-current-cart.js';
|
|
18
16
|
import { useFetchCurrentCartLinesWithAtp } from '../../../shared/api/storefront/hooks/cart/use-fetch-current-cart-lines-with-atp.js';
|
|
@@ -27,22 +25,6 @@ function CartContent({ cartLines }) {
|
|
|
27
25
|
const paths = usePaths();
|
|
28
26
|
const { addToast } = useToast();
|
|
29
27
|
const { data: currentCart } = useFetchCurrentCartWithAtp();
|
|
30
|
-
const saveCartForLater = useSaveCartForLater({
|
|
31
|
-
onError: () => {
|
|
32
|
-
addToast({
|
|
33
|
-
body: jsx(FormattedMessage, { id: "Unable to save cart for later." }),
|
|
34
|
-
isUserDismissable: false,
|
|
35
|
-
messageType: 'danger',
|
|
36
|
-
});
|
|
37
|
-
},
|
|
38
|
-
onSuccess: () => {
|
|
39
|
-
addToast({
|
|
40
|
-
body: jsx(FormattedMessage, { id: "Saved cart for later." }),
|
|
41
|
-
isUserDismissable: false,
|
|
42
|
-
messageType: 'success',
|
|
43
|
-
});
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
28
|
const deleteCurrentCart = useDeleteCurrentCart({
|
|
47
29
|
onError: () => {
|
|
48
30
|
addToast({
|
|
@@ -75,7 +57,6 @@ function CartContent({ cartLines }) {
|
|
|
75
57
|
});
|
|
76
58
|
},
|
|
77
59
|
});
|
|
78
|
-
const isAuthenticated = useIsAuthenticated();
|
|
79
60
|
if (!currentCart)
|
|
80
61
|
return null;
|
|
81
62
|
const currencyCode = getCurrencyCodeBySymbol(currentCart.currencySymbol);
|
|
@@ -83,9 +64,6 @@ function CartContent({ cartLines }) {
|
|
|
83
64
|
throw new Error(`Currency code not found for symbol ${currentCart.currencySymbol}`);
|
|
84
65
|
return (jsx(CheckoutPageLayout, { actions: {
|
|
85
66
|
primary: (jsx(Button, { withArrow: true, "data-test-selector": "checkoutShippingCartTotalContinueButton", href: paths.CHECKOUT_SHIPPING, children: jsx(FormattedMessage, { id: "Start checkout" }) })),
|
|
86
|
-
secondary: isAuthenticated ? (jsx(Button, { color: "secondary", "data-test-selector": "saveCartForLaterButton", onClick: () => {
|
|
87
|
-
saveCartForLater.mutate({ cart: currentCart });
|
|
88
|
-
}, variant: "outline", children: jsx(FormattedMessage, { id: "Save order" }) })) : (jsx(Button, { color: "secondary", "data-test-selector": "saveCartForLaterButton", href: paths.SIGN_IN, variant: "outline", children: jsx(FormattedMessage, { id: "Save order" }) })),
|
|
89
67
|
}, mobileSummary: jsx(CartTotalsSummary, { currencyCode: currencyCode, totalAmount: currentCart.orderGrandTotal }), overview: jsx(CartTotals, { currencyCode: currencyCode, shippingCost: currentCart.shippingAndHandling, subtotal: currentCart.orderSubTotal, tax: currentCart.totalTax, total: currentCart.orderGrandTotal, vatPercentage: cartLines[0]?.pricing?.vatRate || 0 }), children: jsx(OrderLineList, { onRemoveAll: () => deleteCurrentCart.mutate(), children: cartLines.map(cartLine => (jsx(ConnectedOrderLineCard, { deliveryDate: cartLine.atp?.date ?? null, href: cartLine.productUri, image: {
|
|
90
68
|
fit: 'contain',
|
|
91
69
|
image: {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx, jsxs
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { Button } from '../../../buttons/button/button.js';
|
|
4
|
-
import { PrintButton } from '../../../buttons/print-button/print-button.js';
|
|
5
4
|
import { OrderLineCard } from '../../../cards/orderline-card/orderline-card.js';
|
|
6
5
|
import { CartTotals } from '../../../cart-totals/cart-totals.js';
|
|
7
6
|
import { InfoDisplay } from '../../../display/info-display/info-display.js';
|
|
@@ -9,11 +8,9 @@ import { FormattedDate } from '../../../intl/formatted-date.js';
|
|
|
9
8
|
import { FormattedMessage } from '../../../intl/formatted-message.js';
|
|
10
9
|
import { useFormattedMessage } from '../../../intl/use-formatted-message.js';
|
|
11
10
|
import { OrderLineList } from '../../../lists/orderline-list/orderline-list.js';
|
|
12
|
-
import { useSaveCartForLater } from '../../../shared/api/bff/hooks/cart/use-save-cart-for-later.js';
|
|
13
11
|
import { getCurrencyCodeBySymbol } from '../../../shared/model/currency.js';
|
|
14
12
|
import { usePaths } from '../../../shared/routing/use-paths.js';
|
|
15
13
|
import { ensureNumber } from '../../../shared/utils/number.js';
|
|
16
|
-
import { useToast } from '../../../toast/use-toast.js';
|
|
17
14
|
import { Page } from '../../components/page/page.js';
|
|
18
15
|
import { BillingAndInvoiceInformation } from '../components/billing-and-invoice-information.js';
|
|
19
16
|
import { CheckoutPageLayout } from '../layouts/checkout-page-layout/checkout-page-layout.js';
|
|
@@ -24,23 +21,6 @@ import styles from './order-confirmation-page.module.css.js';
|
|
|
24
21
|
function OrderConfirmationPageContent({ cart, }) {
|
|
25
22
|
const t = useFormattedMessage();
|
|
26
23
|
const paths = usePaths();
|
|
27
|
-
const { addToast } = useToast();
|
|
28
|
-
const saveCartForLater = useSaveCartForLater({
|
|
29
|
-
onError: () => {
|
|
30
|
-
addToast({
|
|
31
|
-
body: jsx(FormattedMessage, { id: "Unable to save cart for later." }),
|
|
32
|
-
isUserDismissable: false,
|
|
33
|
-
messageType: 'danger',
|
|
34
|
-
});
|
|
35
|
-
},
|
|
36
|
-
onSuccess: () => {
|
|
37
|
-
addToast({
|
|
38
|
-
body: jsx(FormattedMessage, { id: "Saved cart for later." }),
|
|
39
|
-
isUserDismissable: false,
|
|
40
|
-
messageType: 'success',
|
|
41
|
-
});
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
24
|
const currencyCode = getCurrencyCodeBySymbol(cart.currencySymbol);
|
|
45
25
|
if (!currencyCode)
|
|
46
26
|
throw new Error(`Currency code not found for symbol ${cart.currencySymbol}`);
|
|
@@ -52,9 +32,6 @@ function OrderConfirmationPageContent({ cart, }) {
|
|
|
52
32
|
},
|
|
53
33
|
], "data-test-selector": "orderConfirmationPage", title: t('Order confirmation'), children: jsx(CheckoutPageLayout, { actions: {
|
|
54
34
|
primary: (jsx(Button, { withArrow: true, "data-test-selector": "checkoutReviewAndSubmit_continueShopping", href: paths.HOME, children: jsx(FormattedMessage, { id: "Continue shopping" }) })),
|
|
55
|
-
secondary: (jsxs(Fragment, { children: [cart.canSaveOrder && (jsx(Button, { color: "secondary", onClick: () => {
|
|
56
|
-
saveCartForLater.mutate({ cart });
|
|
57
|
-
}, variant: "outline", children: jsx(FormattedMessage, { id: "Save order" }) })), jsx(PrintButton, {})] })),
|
|
58
35
|
}, overview: jsx(CartTotals, { currencyCode: currencyCode, fulfillmentMethod: cart.fulfillmentMethod, orderNumber: cart.orderNumber, shippingCost: cart.shippingAndHandling, subtotal: cart.orderSubTotal, tax: cart.totalTax, total: cart.orderGrandTotal, vatPercentage: cart.cartLines?.[0]?.pricing?.vatRate }), children: jsxs("div", { children: [jsx(CheckoutPageSection, { hasBorder: false, title: t('General'), children: jsx(CheckoutPageSectionContent, { children: jsxs("div", { className: styles['general-order-info'], children: [cart.orderDate && (jsx(InfoDisplay, { id: "order-date", label: t('Order date'), value: jsx(FormattedDate, { date: cart.orderDate }) })), cart.requestedDeliveryDateDisplay && (jsx(InfoDisplay, { id: "requested-delivery-date", label: t('Requested delivery date'), value: jsx(FormattedDate, { date: cart.requestedDeliveryDateDisplay }) })), cart.poNumber && (jsx(InfoDisplay, { id: "po-number", label: t('PO Number'), value: cart.poNumber }))] }) }) }), jsx(CheckoutPageSection, { hasBorder: false, title: t('Billing and shipping information'), children: jsx(CheckoutPageSectionContent, { children: jsx(BillingAndInvoiceInformation, { billToAddress: cart.billTo && {
|
|
59
36
|
address1: cart.billTo.address1,
|
|
60
37
|
address2: cart.billTo.address2,
|
|
@@ -6,6 +6,7 @@ import { useFetchSession } from '../../../shared/api/storefront/hooks/authentica
|
|
|
6
6
|
import { usePatchSession } from '../../../shared/api/storefront/hooks/authentication/use-patch-session.js';
|
|
7
7
|
import { useFetchCurrentCart } from '../../../shared/api/storefront/hooks/cart/use-fetch-current-cart.js';
|
|
8
8
|
import { useFetchFulfillmentMethodsForCurrentCart } from '../../../shared/api/storefront/hooks/customer/use-fetch-fulfillment-methods-for-current-cart.js';
|
|
9
|
+
import { UnauthorizedRequestError, ForbiddenRequestError } from '../../../shared/fetch/request.js';
|
|
9
10
|
import { useDataLayer } from '../../../shared/ga/use-data-layer.js';
|
|
10
11
|
import { useDisclosure } from '../../../shared/hooks/use-disclosure.js';
|
|
11
12
|
import { useNavigate } from '../../../shared/routing/use-navigate.js';
|
|
@@ -122,7 +123,10 @@ function ShippingPage() {
|
|
|
122
123
|
event: { event: 'add_shipping_info' },
|
|
123
124
|
}));
|
|
124
125
|
}
|
|
125
|
-
catch {
|
|
126
|
+
catch (error) {
|
|
127
|
+
if (error instanceof UnauthorizedRequestError ||
|
|
128
|
+
error instanceof ForbiddenRequestError)
|
|
129
|
+
throw error;
|
|
126
130
|
// Error is tracked by usePatchShippingDetails via isError/error state,
|
|
127
131
|
// surfaced to the UI via errorPatchBillingAddress
|
|
128
132
|
}
|
|
@@ -187,7 +191,10 @@ function ShippingPage() {
|
|
|
187
191
|
event: { event: 'add_shipping_info' },
|
|
188
192
|
}));
|
|
189
193
|
}
|
|
190
|
-
catch {
|
|
194
|
+
catch (error) {
|
|
195
|
+
if (error instanceof UnauthorizedRequestError ||
|
|
196
|
+
error instanceof ForbiddenRequestError)
|
|
197
|
+
throw error;
|
|
191
198
|
// Error is tracked by usePatchShippingDetails via isError/error state,
|
|
192
199
|
// surfaced to the UI via errorPatchBillingAddress
|
|
193
200
|
}
|