@sonic-equipment/ui 258.0.3 → 259.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 +5 -5
- package/dist/footer/connected-footer.d.ts +1 -3
- package/dist/footer/connected-footer.js +2 -2
- package/dist/global-search/search-result-panel/sections/with-results.js +21 -18
- package/dist/header/connected-header.d.ts +1 -3
- package/dist/header/connected-header.js +2 -2
- package/dist/header/header.js +1 -1
- package/dist/index.js +1 -1
- package/dist/pages/checkout/payment-page/payment-page-content.js +1 -1
- package/dist/pages/checkout/payment-page/payment-page.js +1 -7
- package/dist/shared/api/bff/hooks/use-fetch-navigation-links.d.ts +1 -1
- package/dist/shared/api/bff/hooks/use-fetch-navigation-links.js +3 -3
- package/dist/shared/api/bff/services/bff-service.d.ts +1 -4
- package/dist/shared/api/bff/services/bff-service.js +4 -11
- package/dist/shared/utils/environment.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/config.js
CHANGED
|
@@ -23,15 +23,15 @@ const configPerEnvironment = {
|
|
|
23
23
|
ALGOLIA_API_KEY: 'e0edf30798a6b2e4e44fd25f0f2f9646',
|
|
24
24
|
ALGOLIA_APP_ID: 'testing9VXJ0U4GSV',
|
|
25
25
|
ALGOLIA_HOST: 'sonicequipment.commerce.insitesandbox.com',
|
|
26
|
-
BFF_API_URL: 'https://
|
|
27
|
-
COOKIE_DOMAIN: '.
|
|
28
|
-
HOME_PAGE_URL: 'https://
|
|
26
|
+
BFF_API_URL: 'https://sonic.local.com/api/v1/bff',
|
|
27
|
+
COOKIE_DOMAIN: '.local.com',
|
|
28
|
+
HOME_PAGE_URL: 'https://sonic-marketing.local.com/',
|
|
29
29
|
SHOP_API_URL:
|
|
30
30
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
31
|
-
env?.VITE_SHOP_API_URL || 'https://
|
|
31
|
+
env?.VITE_SHOP_API_URL || 'https://sonicshopapi.local.com/',
|
|
32
32
|
SHOP_URL:
|
|
33
33
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
34
|
-
env?.VITE_SHOP_URL || 'https://
|
|
34
|
+
env?.VITE_SHOP_URL || 'https://sonic.local.com:3000/',
|
|
35
35
|
}),
|
|
36
36
|
'next-development': () => ({
|
|
37
37
|
// @ts-expect-error: process is not defined in the browser
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { OnCountryLanguageChangeHandler } from '../country-selector/connected-country-selector';
|
|
2
|
-
|
|
3
|
-
export declare function ConnectedFooter({ className, onCountryLanguageChange, source, }: {
|
|
2
|
+
export declare function ConnectedFooter({ className, onCountryLanguageChange, }: {
|
|
4
3
|
className?: string;
|
|
5
4
|
onCountryLanguageChange: OnCountryLanguageChangeHandler;
|
|
6
|
-
source: NavigationLinkSource;
|
|
7
5
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -8,9 +8,9 @@ import { isNavigationSection } from '../shared/api/bff/model/bff.model.js';
|
|
|
8
8
|
import { useIsAuthenticated } from '../shared/api/storefront/hooks/authentication/use-is-authenticated.js';
|
|
9
9
|
import { Footer } from './footer.js';
|
|
10
10
|
|
|
11
|
-
function ConnectedFooter({ className, onCountryLanguageChange,
|
|
11
|
+
function ConnectedFooter({ className, onCountryLanguageChange, }) {
|
|
12
12
|
const cultureCode = useCultureCode();
|
|
13
|
-
const { data } = useFetchNavigationLinks({ cultureCode
|
|
13
|
+
const { data } = useFetchNavigationLinks({ cultureCode });
|
|
14
14
|
const isAuthenticated = useIsAuthenticated();
|
|
15
15
|
if (data && data.key !== 'navigation')
|
|
16
16
|
throw new Error('Invalid navigation data');
|
|
@@ -56,38 +56,41 @@ function ProductHitCard({ autocomplete, hit, index, source, }) {
|
|
|
56
56
|
// It is just a boolean prop defaulting to true
|
|
57
57
|
const { close } = useGlobalSearchDisclosure();
|
|
58
58
|
const { sendAddToCartFromSearchEvent, sendAddToWishListFromSearchEvent, sendProductClickFromSearchEvent, } = useAlgoliaInsights();
|
|
59
|
+
const { currencyCode, id, image, isVatIncluded, labels, name, objectId, originalPrice, position, price, queryId, storefrontId, storefrontSlug, } = hit;
|
|
60
|
+
const href = storefrontSlug;
|
|
59
61
|
return (jsx(ConnectedProductCard, { ...autocomplete.getItemProps({
|
|
60
62
|
item: hit.hit,
|
|
61
63
|
source,
|
|
62
|
-
}), addToCartEnabled: false, addToFavoritesEnabled: false, href:
|
|
64
|
+
}), addToCartEnabled: false, addToFavoritesEnabled: false, href: href, id: storefrontId, image: {
|
|
63
65
|
fit: 'contain',
|
|
64
|
-
image
|
|
65
|
-
title:
|
|
66
|
-
}, onAddToCart: ({ cartLine }) =>
|
|
66
|
+
image,
|
|
67
|
+
title: name,
|
|
68
|
+
}, onAddToCart: ({ cartLine }) => queryId &&
|
|
67
69
|
sendAddToCartFromSearchEvent({
|
|
68
70
|
cartLine,
|
|
69
|
-
queryId
|
|
71
|
+
queryId,
|
|
70
72
|
}), onClick: () => {
|
|
71
73
|
close();
|
|
72
|
-
if (
|
|
74
|
+
if (queryId) {
|
|
73
75
|
sendProductClickFromSearchEvent({
|
|
74
|
-
objectId
|
|
75
|
-
position:
|
|
76
|
-
queryId
|
|
76
|
+
objectId,
|
|
77
|
+
position: position || index + 1,
|
|
78
|
+
queryId,
|
|
77
79
|
});
|
|
80
|
+
}
|
|
78
81
|
}, onFavoriting: () => {
|
|
79
|
-
if (
|
|
82
|
+
if (queryId)
|
|
80
83
|
sendAddToWishListFromSearchEvent({
|
|
81
|
-
objectId
|
|
82
|
-
position:
|
|
83
|
-
queryId
|
|
84
|
+
objectId,
|
|
85
|
+
position: position || index + 1,
|
|
86
|
+
queryId,
|
|
84
87
|
});
|
|
85
88
|
}, price: {
|
|
86
|
-
currencyCode
|
|
87
|
-
isVatIncluded
|
|
88
|
-
originalPrice
|
|
89
|
-
price
|
|
90
|
-
}, sku:
|
|
89
|
+
currencyCode,
|
|
90
|
+
isVatIncluded,
|
|
91
|
+
originalPrice,
|
|
92
|
+
price,
|
|
93
|
+
}, sku: id, tags: labels, title: jsx(Highlight, { attribute: "name", hit: hit.hit }) }, storefrontId));
|
|
91
94
|
}
|
|
92
95
|
function ProductResultsSection() {
|
|
93
96
|
const { autocomplete, products: collection } = useAlgoliaSearch();
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function ConnectedHeader({ className, source, }: {
|
|
1
|
+
export declare function ConnectedHeader({ className }: {
|
|
3
2
|
className?: string;
|
|
4
|
-
source: NavigationLinkSource;
|
|
5
3
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,9 +5,9 @@ import { useFetchNavigationLinks } from '../shared/api/bff/hooks/use-fetch-navig
|
|
|
5
5
|
import { isNavigationSection } from '../shared/api/bff/model/bff.model.js';
|
|
6
6
|
import { Header } from './header.js';
|
|
7
7
|
|
|
8
|
-
function ConnectedHeader({ className
|
|
8
|
+
function ConnectedHeader({ className }) {
|
|
9
9
|
const cultureCode = useCultureCode();
|
|
10
|
-
const { data } = useFetchNavigationLinks({ cultureCode
|
|
10
|
+
const { data } = useFetchNavigationLinks({ cultureCode });
|
|
11
11
|
if (data && data.key !== 'navigation')
|
|
12
12
|
throw new Error('Invalid navigation data');
|
|
13
13
|
const headerNavigationSection = data?.items
|
package/dist/header/header.js
CHANGED
|
@@ -73,7 +73,7 @@ function Header({ className, headerNavigationSection, sticky, }) {
|
|
|
73
73
|
const mainNavigationSection = headerNavigationSection?.items
|
|
74
74
|
.filter(isNavigationSection)
|
|
75
75
|
.find(item => item.key === 'main-navigation');
|
|
76
|
-
return (jsxs(Fragment, { children: [jsx("header", { ref: headerRef, className: clsx(styles['header'], sticky && styles['sticky'], className), "data-test-selector": "pageHeader", children: jsx(HeaderLayout, { hamburgerButton: jsx(HamburgerButton, { "aria-controls": "mobile-navigation", "data-test-selector": "pageHeaderHamburgerButton", isActive: mobileNavigationOpen, onActiveChange: toggleMobileNavigation }), hasDrawersOpen: hasDrawersOpen, logo: jsx(SonicLogo, { "data-test-selector": "pageHeaderLogo", href: homeLink?.href || undefined, title: t('Home') }), mainNavigation: jsx(NavigationLinkList, { activeLink: activeLinkGroup, "data-test-selector": "pageHeaderMainNavigation", navigationSection: mainNavigationSection, onSubmenuToggle: toggleActiveSubmenu }), navigationActions: jsxs(Fragment, { children: [jsx(ConnectedAccountButton, { "data-test-selector": "pageHeaderAccountButton" }), jsx(ConnectedFavoritesButton, { "data-test-selector": "pageHeaderFavoritesButton", href:
|
|
76
|
+
return (jsxs(Fragment, { children: [jsx("header", { ref: headerRef, className: clsx(styles['header'], sticky && styles['sticky'], className), "data-test-selector": "pageHeader", children: jsx(HeaderLayout, { hamburgerButton: jsx(HamburgerButton, { "aria-controls": "mobile-navigation", "data-test-selector": "pageHeaderHamburgerButton", isActive: mobileNavigationOpen, onActiveChange: toggleMobileNavigation }), hasDrawersOpen: hasDrawersOpen, logo: jsx(SonicLogo, { "data-test-selector": "pageHeaderLogo", href: homeLink?.href || undefined, title: t('Home') }), mainNavigation: jsx(NavigationLinkList, { activeLink: activeLinkGroup, "data-test-selector": "pageHeaderMainNavigation", navigationSection: mainNavigationSection, onSubmenuToggle: toggleActiveSubmenu }), navigationActions: jsxs(Fragment, { children: [jsx(ConnectedAccountButton, { "data-test-selector": "pageHeaderAccountButton" }), jsx(ConnectedFavoritesButton, { "data-test-selector": "pageHeaderFavoritesButton", href: "abc" }), jsx(ConnectedCartButton, { "data-test-selector": "pageHeaderCartButton", href: paths.CART })] }), search: jsx(SearchButton, { "aria-controls": "global-search", "data-test-selector": "pageHeaderSearchButton", isActive: searchOpen, onActiveChange: toggleSearch }) }) }), jsx(SearchDrawer, { groupId: searchGroupId, instanceId: searchInstanceId }), !isXl && (jsx(MobileNavigationDrawer, { groupId: mobileNavigationDrawer.groupId, instanceId: mobileNavigationDrawer.instanceId, linkItems: mainNavigationSection?.items.filter(isNavigationLinkItem) })), isXl && (jsx(DesktopNavigationDrawer, { groupId: desktopNavigationDrawer.groupId, instanceId: desktopNavigationDrawer.instanceId, linkGroup: activeLinkGroup, onClosed: () => setActiveLinkGroup(undefined) }))] }));
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
export { Header };
|
package/dist/index.js
CHANGED
|
@@ -327,7 +327,7 @@ export { useFetchProductDetailsPageData } from './shared/api/bff/hooks/use-fetch
|
|
|
327
327
|
export { useFetchProductListingPageData } from './shared/api/bff/hooks/use-fetch-product-listing-page-data.js';
|
|
328
328
|
export { useFetchProductsPrices } from './shared/api/bff/hooks/use-fetch-products-prices.js';
|
|
329
329
|
export { useFetchRecentlyViewedProducts } from './shared/api/bff/hooks/use-fetch-recently-viewed-products.js';
|
|
330
|
-
export { fetchAnnouncements, fetchNavigationLinks, fetchProductDetailsPageData, fetchProductListingPageData, fetchProductsPrices, fetchRecentlyViewedProducts,
|
|
330
|
+
export { fetchAnnouncements, fetchNavigationLinks, fetchProductDetailsPageData, fetchProductListingPageData, fetchProductsPrices, fetchRecentlyViewedProducts, patchCart, placeOrder, saveCartForLater } from './shared/api/bff/services/bff-service.js';
|
|
331
331
|
export { useAwaitableMutation } from './shared/api/shared/hooks/use-awaitable-mutation.js';
|
|
332
332
|
export { useCreateAccount } from './shared/api/storefront/hooks/account/use-create-account.js';
|
|
333
333
|
export { useCreateGuestAccount } from './shared/api/storefront/hooks/account/use-create-guest-account.js';
|
|
@@ -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,
|
|
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: {
|
|
35
35
|
fit: 'contain',
|
|
36
36
|
image: {
|
|
37
37
|
'1': cartLine.smallImagePath,
|
|
@@ -21,17 +21,11 @@ function PaymentPage({ hasReturnedFromAdyen, }) {
|
|
|
21
21
|
const { data: atp, isLoading: isAtpLoading } = useFetchCurrentCheckoutAtp();
|
|
22
22
|
const hasAtp = atp !== undefined && atp.length > 1;
|
|
23
23
|
const isLoading = isLoadingCart || isAtpLoading;
|
|
24
|
-
const [isProcessing, setIsProcessing] = useState(
|
|
24
|
+
const [isProcessing, setIsProcessing] = useState(false);
|
|
25
25
|
const { isNavigating, navigate } = useNavigate();
|
|
26
26
|
const onPaymentComplete = useCallback(({ cartId }) => {
|
|
27
27
|
navigate(`${paths.ORDER_CONFIRMATION}?cartId=${cartId}`);
|
|
28
28
|
}, [navigate, paths]);
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
const setProcessingOn = async () => setIsProcessing(true);
|
|
31
|
-
if (hasReturnedFromAdyen) {
|
|
32
|
-
setProcessingOn();
|
|
33
|
-
}
|
|
34
|
-
}, [hasReturnedFromAdyen, setIsProcessing]);
|
|
35
29
|
useEffect(() => {
|
|
36
30
|
if (isNavigating)
|
|
37
31
|
return;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { FetchNavigationLinksArgs } from '../services/bff-service';
|
|
2
|
-
export declare function useFetchNavigationLinks({ cultureCode,
|
|
2
|
+
export declare function useFetchNavigationLinks({ cultureCode, }: FetchNavigationLinksArgs): import("@tanstack/react-query").UseQueryResult<import("../model/bff.model").NavigationSection, Error>;
|
|
@@ -3,11 +3,11 @@ import { useQuery } from '@tanstack/react-query';
|
|
|
3
3
|
import { TIME } from '../../../utils/time.js';
|
|
4
4
|
import { fetchNavigationLinks } from '../services/bff-service.js';
|
|
5
5
|
|
|
6
|
-
function useFetchNavigationLinks({ cultureCode,
|
|
6
|
+
function useFetchNavigationLinks({ cultureCode, }) {
|
|
7
7
|
return useQuery({
|
|
8
8
|
gcTime: 1 * TIME.DAY,
|
|
9
|
-
queryFn: () => fetchNavigationLinks({ cultureCode
|
|
10
|
-
queryKey: ['navigation',
|
|
9
|
+
queryFn: () => fetchNavigationLinks({ cultureCode }),
|
|
10
|
+
queryKey: ['navigation', cultureCode],
|
|
11
11
|
refetchInterval: 5 * TIME.MINUTE,
|
|
12
12
|
staleTime: 1 * TIME.DAY,
|
|
13
13
|
});
|
|
@@ -15,13 +15,10 @@ export interface FetchProductPageDataArgs {
|
|
|
15
15
|
}
|
|
16
16
|
export declare function fetchProductDetailsPageData({ cultureCode, headers, ignoreCache, pageUrl, }: FetchProductPageDataArgs & APIArguments): Promise<ProductDetailsPageDataResponse>;
|
|
17
17
|
export declare function fetchProductListingPageData({ cultureCode, headers, ignoreCache, pageUrl, }: FetchProductPageDataArgs & APIArguments): Promise<ProductListingPageData>;
|
|
18
|
-
export type NavigationLinkSource = 'shop' | 'marketing';
|
|
19
|
-
export declare function isNavigationLinkSource(value: unknown): value is NavigationLinkSource;
|
|
20
18
|
export interface FetchNavigationLinksArgs {
|
|
21
19
|
cultureCode: CultureCode;
|
|
22
|
-
source: NavigationLinkSource;
|
|
23
20
|
}
|
|
24
|
-
export declare function fetchNavigationLinks({ cultureCode, headers, ignoreCache,
|
|
21
|
+
export declare function fetchNavigationLinks({ cultureCode, headers, ignoreCache, }: FetchNavigationLinksArgs & APIArguments): Promise<NavigationResponse>;
|
|
25
22
|
export declare function fetchRecentlyViewedProducts({ cultureCode, }: {
|
|
26
23
|
cultureCode: CultureCode;
|
|
27
24
|
}): Promise<ProductSummary[]>;
|
|
@@ -97,21 +97,14 @@ async function fetchProductListingPageData({ cultureCode, headers, ignoreCache,
|
|
|
97
97
|
})),
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
|
-
function
|
|
101
|
-
return value === 'shop' || value === 'marketing';
|
|
102
|
-
}
|
|
103
|
-
async function fetchNavigationLinks({ cultureCode, headers, ignoreCache, source, }) {
|
|
100
|
+
async function fetchNavigationLinks({ cultureCode, headers, ignoreCache, }) {
|
|
104
101
|
const { body } = await request({
|
|
105
|
-
headers: { 'Current-Language-Id': cultureCode,
|
|
102
|
+
headers: { 'Current-Language-Id': cultureCode, ...headers },
|
|
106
103
|
next: {
|
|
107
104
|
revalidate: ignoreCache ? 0 : Infinity,
|
|
108
105
|
tags: ignoreCache
|
|
109
106
|
? undefined
|
|
110
|
-
: [
|
|
111
|
-
'navigation',
|
|
112
|
-
`navigation-${source}`,
|
|
113
|
-
`navigation-${source}-${cultureCode}`,
|
|
114
|
-
],
|
|
107
|
+
: ['navigation', `navigation-${cultureCode}`],
|
|
115
108
|
},
|
|
116
109
|
url: `${config.BFF_API_URL}/v2/navigation`,
|
|
117
110
|
});
|
|
@@ -183,4 +176,4 @@ async function saveCartForLater({ cart }) {
|
|
|
183
176
|
return body;
|
|
184
177
|
}
|
|
185
178
|
|
|
186
|
-
export { fetchAnnouncements, fetchNavigationLinks, fetchProductDetailsPageData, fetchProductListingPageData, fetchProductsPrices, fetchRecentlyViewedProducts,
|
|
179
|
+
export { fetchAnnouncements, fetchNavigationLinks, fetchProductDetailsPageData, fetchProductListingPageData, fetchProductsPrices, fetchRecentlyViewedProducts, patchCart, placeOrder, saveCartForLater };
|
|
@@ -12,7 +12,7 @@ const environments = [
|
|
|
12
12
|
];
|
|
13
13
|
const marketingLocal = /marketing.local.com/i;
|
|
14
14
|
const storybookUrls = /localhost:6006|storybook.sonic.local.com/i;
|
|
15
|
-
const localUrls = /sonic.local.com/i;
|
|
15
|
+
const localUrls = /sonic.local.com/i; // used for detecting old Spire local development environment, new NextJS local environment uses next-development
|
|
16
16
|
const reverseProxyUrls = /sonic-equipment.workers.dev/i;
|
|
17
17
|
const sandboxUrls = /local|insitesandbox.com|azurestaticapps|ui.sonic-equipment.com|sandbox|accept|test/i;
|
|
18
18
|
const productionUrls = /sonic-equipment.com|production/i;
|
package/dist/styles.css
CHANGED