@sonic-equipment/ui 253.0.0 → 255.0.0
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/config.js +3 -3
- package/dist/index.js +1 -1
- package/dist/media/image/image.js +4 -4
- package/dist/pages/checkout/payment-page/payment-page.d.ts +3 -1
- package/dist/pages/checkout/payment-page/payment-page.js +1 -3
- package/dist/pages/checkout/shipping-page/components/readonly-address.js +4 -1
- package/dist/pages/my-sonic/actions/change-customer/connected-change-customer-dialog.js +9 -2
- package/dist/pages/my-sonic/actions/create-ship-to-address/connected-create-ship-to-address-form.d.ts +2 -1
- package/dist/pages/my-sonic/actions/create-ship-to-address/connected-create-ship-to-address-form.js +2 -2
- package/dist/pages/my-sonic/pages/create-ship-to-address-details-page/create-ship-to-address-details-page.d.ts +2 -1
- package/dist/pages/my-sonic/pages/create-ship-to-address-details-page/create-ship-to-address-details-page.js +2 -2
- package/dist/shared/api/storefront/services/customer-service.d.ts +3 -0
- package/dist/shared/api/storefront/services/customer-service.js +8 -1
- package/package.json +1 -1
package/dist/config.js
CHANGED
|
@@ -70,11 +70,11 @@ const configPerEnvironment = {
|
|
|
70
70
|
production: () => ({
|
|
71
71
|
ALGOLIA_API_KEY: 'e31a3a53449eceb4d0f9273b9bcd9759',
|
|
72
72
|
ALGOLIA_APP_ID: '14CUFCVMAD',
|
|
73
|
-
ALGOLIA_HOST: '
|
|
74
|
-
BFF_API_URL: 'https://
|
|
73
|
+
ALGOLIA_HOST: 'shopapi.sonic-equipment.com',
|
|
74
|
+
BFF_API_URL: 'https://shopapi.sonic-equipment.com/api/v1/bff',
|
|
75
75
|
COOKIE_DOMAIN: '.sonic-equipment.com',
|
|
76
76
|
HOME_PAGE_URL: 'https://sonic-equipment.com/',
|
|
77
|
-
SHOP_API_URL: 'https://
|
|
77
|
+
SHOP_API_URL: 'https://shopapi.sonic-equipment.com',
|
|
78
78
|
SHOP_URL: 'https://shop.sonic-equipment.com',
|
|
79
79
|
}),
|
|
80
80
|
sandbox: () => ({
|
package/dist/index.js
CHANGED
|
@@ -390,7 +390,7 @@ export { ExistingAccountError, createAccount, createGuestAccount, fetchCurrentAc
|
|
|
390
390
|
export { AccountLockedOutError, InvalidEmailPasswordCombinationError, InvalidGrantError, InvalidPasswordError, NonUniquePasswordError, UnableToChangePasswordError, UserNotFoundError, createSession, fetchSession, patchSession, recoverPassword, signIn, signOut } from './shared/api/storefront/services/authentication-service.js';
|
|
391
391
|
export { addBulkProductsToCurrentCart, addProductToCurrentCart, convertToMinorUnits, deleteCartLineById, deleteCurrentCart, fetchCart, fetchCurrentCart, fetchCurrentCartLines, fetchCurrentCartProductAtp, fetchCurrentCartPromotions, fetchCurrentCheckoutAtp, getAdyenPaymentDetails, patchCartLineById, postAdyenPayment } from './shared/api/storefront/services/cart-service.js';
|
|
392
392
|
export { fetchCategories } from './shared/api/storefront/services/category-service.js';
|
|
393
|
-
export { fetchBillToAddress, fetchBillToAddresses, fetchCurrentBillToAddress, fetchCurrentShipToAddress, fetchFulfillmentMethods, fetchPagedShipToAddresses, fetchShipToAddress, fetchShipToAddresses, patchBillToAddress, patchShipToAddress, postShipToAddress } from './shared/api/storefront/services/customer-service.js';
|
|
393
|
+
export { fetchBillToAddress, fetchBillToAddresses, fetchCurrentBillToAddress, fetchCurrentShipToAddress, fetchFulfillmentMethods, fetchPagedShipToAddresses, fetchShipByBillTo, fetchShipToAddress, fetchShipToAddresses, patchBillToAddress, patchShipToAddress, postShipToAddress } from './shared/api/storefront/services/customer-service.js';
|
|
394
394
|
export { validateVATNumber } from './shared/api/storefront/services/finance-service.js';
|
|
395
395
|
export { fetchOrderById, fetchOrders } from './shared/api/storefront/services/order-service.js';
|
|
396
396
|
export { createAdyenSession, fetchAdyenConfig } from './shared/api/storefront/services/payment-service.js';
|
|
@@ -27,9 +27,9 @@ function Image({ className, 'data-test-selector': dataTestSelector, fallbackSrc
|
|
|
27
27
|
}
|
|
28
28
|
function createSrcSet(image) {
|
|
29
29
|
return ([
|
|
30
|
-
image[1] && `${image[1]} 1x`,
|
|
31
|
-
image[2] && `${image[2]} 2x`,
|
|
32
|
-
image[3] && `${image[3]} 3x`,
|
|
30
|
+
image[1] && `${encodeURI(image[1])} 1x`,
|
|
31
|
+
image[2] && `${encodeURI(image[2])} 2x`,
|
|
32
|
+
image[3] && `${encodeURI(image[3])} 3x`,
|
|
33
33
|
]
|
|
34
34
|
.filter(Boolean)
|
|
35
35
|
.join(', ') || undefined);
|
|
@@ -57,7 +57,7 @@ function PictureComponent({ className, fallbackSrc, fit = 'cover', hasError, ima
|
|
|
57
57
|
return (jsx("picture", { className: clsx(styles.picture, className), children: jsx("img", { alt: "Missing", className: clsx(styles.image, styles[fit], styles['has-error']), src: fallbackSrc, ...rest }) }));
|
|
58
58
|
return (jsxs("picture", { className: clsx(styles.picture, className), children: [image.sm && (jsx("source", { media: "(max-width: 768px)", srcSet: createSrcSet(image.sm) })), image.md && (jsx("source", { media: "(max-width: 1439px)", srcSet: createSrcSet(image.md) })), image.lg && (jsx("source", { media: "(min-width: 1440px)", srcSet: createSrcSet(image.lg) })), jsx("img", { alt: image.altText, className: clsx(styles.image, styles[fit], {
|
|
59
59
|
[styles['has-error']]: hasError,
|
|
60
|
-
}), src: hasError ? fallbackSrc : getPrimarySrc(image), ...rest })] }));
|
|
60
|
+
}), src: encodeURI((hasError ? fallbackSrc : getPrimarySrc(image)) || ''), ...rest })] }));
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
export { Image };
|
|
@@ -9,13 +9,11 @@ import { usePaths } from '../../../shared/routing/use-paths.js';
|
|
|
9
9
|
import { hasNo } from '../../../shared/utils/types.js';
|
|
10
10
|
import { ErrorPage } from '../../error-page/error-page.js';
|
|
11
11
|
import { LoadingPage } from '../../loading-page/loading-page.js';
|
|
12
|
-
import { useHasReturnedFromAdyen } from './hooks/use-has-returned-from-adyen.js';
|
|
13
12
|
import { PaymentPageContent } from './payment-page-content.js';
|
|
14
13
|
|
|
15
14
|
const PAYMENT_FORM_ID = 'paymentForm';
|
|
16
|
-
function PaymentPage() {
|
|
15
|
+
function PaymentPage({ hasReturnedFromAdyen, }) {
|
|
17
16
|
const paths = usePaths();
|
|
18
|
-
const hasReturnedFromAdyen = useHasReturnedFromAdyen();
|
|
19
17
|
const isAuthenticated = useIsAuthenticated();
|
|
20
18
|
const { data: cart, error, isLoading: isLoadingCart, } = useFetchCurrentCartWithAtp({
|
|
21
19
|
forceRecalculation: !hasReturnedFromAdyen,
|
|
@@ -24,11 +24,14 @@ function ReadOnlyAddresses({ billTo, isLoading, isPickup, notes, onSubmit, shipT
|
|
|
24
24
|
const href = `${pathname}${search}`;
|
|
25
25
|
const billToId = billTo?.id;
|
|
26
26
|
const shipToId = shipTo?.id;
|
|
27
|
+
const isShipToABillToAddress = billToId && shipToId && billToId === shipToId;
|
|
27
28
|
const editBillToAddressUrl = environment.includes('next')
|
|
28
29
|
? `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/${billToId}?returnUrl=${encodeURIComponent(href)}`
|
|
29
30
|
: paths.ACCOUNT_ADDRESSES;
|
|
30
31
|
const editShipToAddressUrl = environment.includes('next')
|
|
31
|
-
?
|
|
32
|
+
? isShipToABillToAddress
|
|
33
|
+
? `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/${billToId}${paths.ACCOUNT_EDIT_SHIP_TO_ADDRESS}/new?returnUrl=${encodeURIComponent(href)}&makeDefault=true`
|
|
34
|
+
: `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/${billToId}${paths.ACCOUNT_EDIT_SHIP_TO_ADDRESS}/${shipToId}?returnUrl=${encodeURIComponent(href)}`
|
|
32
35
|
: paths.ACCOUNT_ADDRESSES;
|
|
33
36
|
return (jsxs(Form, { id: EDIT_ADDRESS_FORM_ID, onSubmit: e => {
|
|
34
37
|
e.preventDefault();
|
|
@@ -4,6 +4,7 @@ import { useState, useEffect } from 'react';
|
|
|
4
4
|
import { useFetchCurrentAccount } from '../../../../shared/api/storefront/hooks/account/use-fetch-current-account.js';
|
|
5
5
|
import { usePatchSession } from '../../../../shared/api/storefront/hooks/authentication/use-patch-session.js';
|
|
6
6
|
import { useFetchBillToAddresses } from '../../../../shared/api/storefront/hooks/customer/use-fetch-bill-to-addresses.js';
|
|
7
|
+
import { fetchShipByBillTo } from '../../../../shared/api/storefront/services/customer-service.js';
|
|
7
8
|
import { ChangeCustomerDialog } from './change-customer-dialog.js';
|
|
8
9
|
|
|
9
10
|
function ConnectedChangeCustomerDialog({ allowSetDefault = false, isOpen, onClose, onCustomerSelected, }) {
|
|
@@ -17,6 +18,12 @@ function ConnectedChangeCustomerDialog({ allowSetDefault = false, isOpen, onClos
|
|
|
17
18
|
useEffect(() => reset(), [isOpen, reset]);
|
|
18
19
|
return (jsx(ChangeCustomerDialog, { allowSetDefault: allowSetDefault, data: data, defaultCustomerId: account?.defaultCustomerId || undefined, error: error, filter: filter, hasErrorSubmitting: Boolean(errorMutation), isLoading: isLoading || isFetching, isOpen: isOpen, isUpdating: isMutating, onClose: onClose, onCustomerSelected: async (id, setAsDefault) => {
|
|
19
20
|
id = `${id}`;
|
|
21
|
+
const shipToAddress = await fetchShipByBillTo({ billToId: id });
|
|
22
|
+
const defaultShipTo = shipToAddress.shipTos?.find(shipTo => shipTo.isDefault);
|
|
23
|
+
const firstShipToWithId = shipToAddress.shipTos?.find(shipTo => shipTo.id !== '');
|
|
24
|
+
const shipToId = defaultShipTo
|
|
25
|
+
? defaultShipTo.id
|
|
26
|
+
: (firstShipToWithId?.id ?? id);
|
|
20
27
|
try {
|
|
21
28
|
await mutate({
|
|
22
29
|
session: {
|
|
@@ -28,8 +35,8 @@ function ConnectedChangeCustomerDialog({ allowSetDefault = false, isOpen, onClos
|
|
|
28
35
|
customerWasUpdated: false,
|
|
29
36
|
fulfillmentMethod: 'Ship',
|
|
30
37
|
pickUpWarehouse: null,
|
|
31
|
-
shipTo: { id },
|
|
32
|
-
shipToId
|
|
38
|
+
shipTo: { id: shipToId },
|
|
39
|
+
shipToId,
|
|
33
40
|
},
|
|
34
41
|
});
|
|
35
42
|
onCustomerSelected(id, setAsDefault);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export declare function ConnectedCreateShipToAddressForm({ billToId, returnUrl, }: {
|
|
1
|
+
export declare function ConnectedCreateShipToAddressForm({ billToId, makeDefault, returnUrl, }: {
|
|
2
2
|
billToId: string;
|
|
3
|
+
makeDefault?: boolean;
|
|
3
4
|
returnUrl?: string;
|
|
4
5
|
}): import("react/jsx-runtime").JSX.Element;
|
package/dist/pages/my-sonic/actions/create-ship-to-address/connected-create-ship-to-address-form.js
CHANGED
|
@@ -18,7 +18,7 @@ import { LoadingPage } from '../../../loading-page/loading-page.js';
|
|
|
18
18
|
import formStyles from '../../../../forms/partials/address-form/address-form.module.css.js';
|
|
19
19
|
import styles from './create-ship-to-address.module.css.js';
|
|
20
20
|
|
|
21
|
-
function ConnectedCreateShipToAddressForm({ billToId, returnUrl, }) {
|
|
21
|
+
function ConnectedCreateShipToAddressForm({ billToId, makeDefault, returnUrl, }) {
|
|
22
22
|
const paths = usePaths();
|
|
23
23
|
const { navigate } = useNavigate();
|
|
24
24
|
const { countries, currentCountry, error: errorCountries, isFetching: isLoadingCountries, } = useCountries();
|
|
@@ -83,7 +83,7 @@ function ConnectedCreateShipToAddressForm({ billToId, returnUrl, }) {
|
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
return navigate(`${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/${billToId}${paths.ACCOUNT_EDIT_SHIP_TO_ADDRESS}/${createdShipToAddress.id}?returnUrl=${encodeURIComponent(returnUrl || '')}`);
|
|
86
|
-
}, children: [jsx(AddressForm, { address: undefined, countries: countries, currentCountry: currentCountry, isLoading: isPatching }), jsx(Checkbox, { isDisabled: isPatching, name: "setAsDefault", value: "TRUE", children: jsx(FormattedMessage, { id: "Make this the default ship to address" }) }), Boolean(errorShipToAddress) && (jsx("div", { className: styles.info, children: jsx(Message, { type: "danger", children: jsx(FormattedMessage, { id: "An unexpected error occured" }) }) })), isSuccess && !isPatching && (jsx("div", { className: styles.info, children: jsx(Message, { type: "info", children: jsx(FormattedMessage, { id: "Saved" }) }) })), jsxs("div", { className: styles.actions, children: [returnUrl && (jsx(Button, { color: "secondary", isDisabled: isPatching, onClick: () => navigate(returnUrl), variant: "outline", children: jsx(FormattedMessage, { id: "Back" }) })), jsx(Button, { isLoading: isPatching ? jsx(FormattedMessage, { id: "Saving" }) : undefined, type: "submit", children: jsx(FormattedMessage, { id: "Save" }) })] })] }));
|
|
86
|
+
}, children: [jsx(AddressForm, { address: undefined, countries: countries, currentCountry: currentCountry, isLoading: isPatching }), jsx(Checkbox, { defaultSelected: makeDefault, isDisabled: isPatching, name: "setAsDefault", value: "TRUE", children: jsx(FormattedMessage, { id: "Make this the default ship to address" }) }), Boolean(errorShipToAddress) && (jsx("div", { className: styles.info, children: jsx(Message, { type: "danger", children: jsx(FormattedMessage, { id: "An unexpected error occured" }) }) })), isSuccess && !isPatching && (jsx("div", { className: styles.info, children: jsx(Message, { type: "info", children: jsx(FormattedMessage, { id: "Saved" }) }) })), jsxs("div", { className: styles.actions, children: [returnUrl && (jsx(Button, { color: "secondary", isDisabled: isPatching, onClick: () => navigate(returnUrl), variant: "outline", children: jsx(FormattedMessage, { id: "Back" }) })), jsx(Button, { isLoading: isPatching ? jsx(FormattedMessage, { id: "Saving" }) : undefined, type: "submit", children: jsx(FormattedMessage, { id: "Save" }) })] })] }));
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
export { ConnectedCreateShipToAddressForm };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export declare function CreateShipToAddressDetailsPage({ billToId, returnUrl, }: {
|
|
1
|
+
export declare function CreateShipToAddressDetailsPage({ billToId, makeDefault, returnUrl, }: {
|
|
2
2
|
billToId: string;
|
|
3
|
+
makeDefault?: boolean;
|
|
3
4
|
returnUrl?: string;
|
|
4
5
|
}): import("react/jsx-runtime").JSX.Element;
|
|
5
6
|
export declare function CreateShipToAddressDetailsPageBreadcrumb({ billToId, }: {
|
|
@@ -7,10 +7,10 @@ import { ConnectedCreateShipToAddressForm } from '../../actions/create-ship-to-a
|
|
|
7
7
|
import { MySonicLayoutBreadcrumb } from '../../layouts/my-sonic-layout/my-sonic-layout-breadcrumb.js';
|
|
8
8
|
import { MySonicLayoutPage } from '../../layouts/my-sonic-layout/my-sonic-layout-page.js';
|
|
9
9
|
|
|
10
|
-
function CreateShipToAddressDetailsPage({ billToId, returnUrl, }) {
|
|
10
|
+
function CreateShipToAddressDetailsPage({ billToId, makeDefault, returnUrl, }) {
|
|
11
11
|
const t = useFormattedMessage();
|
|
12
12
|
const paths = usePaths();
|
|
13
|
-
return (jsx(MySonicLayoutPage, { title: t('Shipping address'), children: jsx(ConnectedCreateShipToAddressForm, { billToId: billToId, returnUrl: returnUrl || paths.ACCOUNT }) }));
|
|
13
|
+
return (jsx(MySonicLayoutPage, { title: t('Shipping address'), children: jsx(ConnectedCreateShipToAddressForm, { billToId: billToId, makeDefault: makeDefault, returnUrl: returnUrl || paths.ACCOUNT }) }));
|
|
14
14
|
}
|
|
15
15
|
function CreateShipToAddressDetailsPageBreadcrumb({ billToId, }) {
|
|
16
16
|
const t = useFormattedMessage();
|
|
@@ -14,6 +14,9 @@ export declare function fetchShipToAddress({ billToId, includeValidation, shipTo
|
|
|
14
14
|
includeValidation?: boolean;
|
|
15
15
|
shipToId: string;
|
|
16
16
|
}): Promise<ShipToModel>;
|
|
17
|
+
export declare function fetchShipByBillTo({ billToId }: {
|
|
18
|
+
billToId: string;
|
|
19
|
+
}): Promise<ShipToCollectionModel>;
|
|
17
20
|
export interface FetchBillToAddressesParams {
|
|
18
21
|
filter?: string;
|
|
19
22
|
pageSize?: number;
|
|
@@ -25,6 +25,13 @@ async function fetchShipToAddress({ billToId, includeValidation = false, shipToI
|
|
|
25
25
|
});
|
|
26
26
|
return body;
|
|
27
27
|
}
|
|
28
|
+
async function fetchShipByBillTo({ billToId }) {
|
|
29
|
+
const { body } = await request({
|
|
30
|
+
credentials: 'include',
|
|
31
|
+
url: `${config.SHOP_API_URL}/api/v1/billtos/${billToId}/shiptos`,
|
|
32
|
+
});
|
|
33
|
+
return body;
|
|
34
|
+
}
|
|
28
35
|
async function fetchBillToAddresses({ filter, pageSize = 20, } = {}) {
|
|
29
36
|
const { body } = await request({
|
|
30
37
|
credentials: 'include',
|
|
@@ -102,4 +109,4 @@ async function fetchFulfillmentMethods({ customerId, }) {
|
|
|
102
109
|
return updatedBillTo;
|
|
103
110
|
}
|
|
104
111
|
|
|
105
|
-
export { fetchBillToAddress, fetchBillToAddresses, fetchCurrentBillToAddress, fetchCurrentShipToAddress, fetchFulfillmentMethods, fetchPagedShipToAddresses, fetchShipToAddress, fetchShipToAddresses, patchBillToAddress, patchShipToAddress, postShipToAddress };
|
|
112
|
+
export { fetchBillToAddress, fetchBillToAddresses, fetchCurrentBillToAddress, fetchCurrentShipToAddress, fetchFulfillmentMethods, fetchPagedShipToAddresses, fetchShipByBillTo, fetchShipToAddress, fetchShipToAddresses, patchBillToAddress, patchShipToAddress, postShipToAddress };
|