@sonic-equipment/ui 1.1.5 → 1.1.7

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.
@@ -70,7 +70,7 @@ function Header({ className, headerNavigationSection, sticky, }) {
70
70
  const mainNavigationSection = headerNavigationSection?.items
71
71
  .filter(isNavigationSection)
72
72
  .find(item => item.key === 'main-navigation');
73
- 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: "/", 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) }))] }));
73
+ 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: "/", 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: paths.FAVORITES }), 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) }))] }));
74
74
  }
75
75
 
76
76
  export { Header };
@@ -1,11 +1,10 @@
1
1
  import { BillToModel, PatchCartModel, PostShipToModel, ShipToModel } from '../../../../shared/api/storefront/model/storefront.model';
2
2
  import { Country } from '../../../../shared/model/countries-languages';
3
- export declare function ReadOnlyAddresses({ billTo, cartId, countries, currentCountry, hasVatNumber, isLoading, isPickup, notes, onSubmit, shipTo, }: {
3
+ export declare function ReadOnlyAddresses({ billTo, cartId, countries, currentCountry, isLoading, isPickup, notes, onSubmit, shipTo, }: {
4
4
  billTo: BillToModel | undefined | null;
5
5
  cartId: string;
6
6
  countries: Country[];
7
7
  currentCountry?: Country | undefined;
8
- hasVatNumber: boolean;
9
8
  isLoading: boolean;
10
9
  isPickup: boolean;
11
10
  notes: string | undefined;
@@ -1,12 +1,11 @@
1
1
  "use client";
2
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
3
  import { Form } from 'react-aria-components';
4
4
  import { AddressInfoDisplay } from '../../../../address-info-display/address-info-display.js';
5
5
  import { TextField } from '../../../../forms/fields/text-field/text-field.js';
6
6
  import { AddressForm } from '../../../../forms/partials/address-form/address-form.js';
7
7
  import { FormattedMessage } from '../../../../intl/formatted-message.js';
8
8
  import { useFormattedMessage } from '../../../../intl/use-formatted-message.js';
9
- import { Message } from '../../../../message/message.js';
10
9
  import { CheckoutPageSection } from '../../layouts/checkout-page-layout/components/checkout-page-section.js';
11
10
  import { CheckoutPageSectionContent } from '../../layouts/checkout-page-layout/components/checkout-page-section-content.js';
12
11
  import { AddressBookSelector } from './address-book-selector.js';
@@ -15,7 +14,7 @@ import ShipToModeSelector from './ship-to-mode-selector.js';
15
14
  import { SonicAddress } from './sonic-address.js';
16
15
  import styles from './readonly-address.module.css.js';
17
16
 
18
- function ReadOnlyAddresses({ billTo, cartId, countries, currentCountry, hasVatNumber, isLoading, isPickup, notes, onSubmit, shipTo, }) {
17
+ function ReadOnlyAddresses({ billTo, cartId, countries, currentCountry, isLoading, isPickup, notes, onSubmit, shipTo, }) {
19
18
  const t = useFormattedMessage();
20
19
  const billToId = billTo?.id;
21
20
  const shipToId = shipTo?.id;
@@ -122,7 +121,7 @@ function ReadOnlyAddresses({ billTo, cartId, countries, currentCountry, hasVatNu
122
121
  lastName: billTo.lastName,
123
122
  phone: billTo.phone,
124
123
  postalCode: billTo.postalCode,
125
- }, "data-test-selector": "billToAddress" })), jsx("div", { className: styles.notes, children: jsx(TextField, { defaultValue: notes, isDisabled: isLoading, isMultiline: true, label: t('Add order notes'), name: "notes", rows: 3, showLabel: true }) })] }) }), jsx(CheckoutPageSection, { title: jsx(FormattedMessage, { id: isPickup ? 'Pickup address' : 'Shipping address' }), children: jsx(CheckoutPageSectionContent, { stretch: true, children: isPickup ? (jsx(SonicAddress, {})) : hasVatNumber ? (jsxs(Fragment, { children: [jsx(Message, { type: "info", children: jsx(FormattedMessage, { id: "Your VAT number is set, so the shipping address for this order cannot be changed. Please complete or empty this order, then update your shipping address from your account." }) }), shipToInfoDisplay] })) : (jsx(ShipToModeSelector, { addressBookSelector: billTo?.id && (jsx("div", { className: styles['address-book-selector'], children: jsx(AddressBookSelector, { billToId: billTo.id, currentShipToId: shipTo?.id }) })), defaultShippingOption: isShipToABillToAddress
124
+ }, "data-test-selector": "billToAddress" })), jsx("div", { className: styles.notes, children: jsx(TextField, { defaultValue: notes, isDisabled: isLoading, isMultiline: true, label: t('Add order notes'), name: "notes", rows: 3, showLabel: true }) })] }) }), jsx(CheckoutPageSection, { title: jsx(FormattedMessage, { id: isPickup ? 'Pickup address' : 'Shipping address' }), children: jsx(CheckoutPageSectionContent, { stretch: true, children: isPickup ? (jsx(SonicAddress, {})) : (jsx(ShipToModeSelector, { addressBookSelector: billTo?.id && (jsx("div", { className: styles['address-book-selector'], children: jsx(AddressBookSelector, { billToId: billTo.id, currentShipToId: shipTo?.id }) })), defaultShippingOption: isShipToABillToAddress
126
125
  ? 'useBillTo'
127
126
  : shipTo
128
127
  ? 'selectFromAddressBook'
@@ -159,7 +159,7 @@ function ShippingPage() {
159
159
  },
160
160
  });
161
161
  await refetchCart();
162
- }, readOnlyAddress: jsx(ReadOnlyAddresses, { billTo: cart.billTo, cartId: cart.id, countries: countries || [], currentCountry: currentCountry, hasVatNumber: Boolean(cart.customerVatNumber), isLoading: isPatching, isPickup: isPickup, notes: cart.notes, onSubmit: async ({ cart: updatedCart, notes, shipTo }) => {
162
+ }, readOnlyAddress: jsx(ReadOnlyAddresses, { billTo: cart.billTo, cartId: cart.id, countries: countries || [], currentCountry: currentCountry, isLoading: isPatching, isPickup: isPickup, notes: cart.notes, onSubmit: async ({ cart: updatedCart, notes, shipTo }) => {
163
163
  if (!cart.billTo)
164
164
  return;
165
165
  if (notes ||
@@ -41,6 +41,9 @@ function OrderHistoryPage() {
41
41
  });
42
42
  const [page, setPage] = useState(1);
43
43
  const { data, error, isFetching } = useFetchOrders({
44
+ // Forces Optimizely to return orders for all ShipTo addresses instead of
45
+ // only those without a customer sequence.
46
+ customerSequence: '-1',
44
47
  page,
45
48
  pageSize: 20,
46
49
  search,
@@ -1,5 +1,6 @@
1
1
  import { OrderStatus, SortOption } from '../../model/storefront.model';
2
- export declare function useFetchOrders({ enabled, page, pageSize, search, sort, status, }?: {
2
+ export declare function useFetchOrders({ customerSequence, enabled, page, pageSize, search, sort, status, }?: {
3
+ customerSequence?: string;
3
4
  enabled?: boolean;
4
5
  page: number;
5
6
  pageSize: number;
@@ -2,12 +2,20 @@
2
2
  import { useQuery } from '@tanstack/react-query';
3
3
  import { fetchOrders } from '../../services/order-service.js';
4
4
 
5
- function useFetchOrders({ enabled = true, page = 1, pageSize = 20, search, sort, status, } = { enabled: true, page: 1, pageSize: 20, search: '' }) {
5
+ function useFetchOrders({ customerSequence, enabled = true, page = 1, pageSize = 20, search, sort, status, } = { enabled: true, page: 1, pageSize: 20, search: '' }) {
6
6
  return useQuery({
7
7
  enabled,
8
8
  placeholderData: prev => prev,
9
- queryFn: () => fetchOrders({ page, pageSize, search, sort, status }),
10
- queryKey: ['orders', page, pageSize, search, sort, status],
9
+ queryFn: () => fetchOrders({ customerSequence, page, pageSize, search, sort, status }),
10
+ queryKey: [
11
+ 'orders',
12
+ page,
13
+ pageSize,
14
+ search,
15
+ sort,
16
+ status,
17
+ customerSequence,
18
+ ],
11
19
  });
12
20
  }
13
21
 
@@ -1,5 +1,6 @@
1
1
  import { OrderCollectionModel, OrderModel, OrderStatus, SortOption } from '../model/storefront.model';
2
- export declare function fetchOrders({ page, pageSize, search, sort, status, }?: {
2
+ export declare function fetchOrders({ customerSequence, page, pageSize, search, sort, status, }?: {
3
+ customerSequence?: string;
3
4
  page?: number;
4
5
  pageSize?: number;
5
6
  search?: string;
@@ -2,7 +2,7 @@ import { config } from '../../../../config.js';
2
2
  import { request } from '../../../fetch/request.js';
3
3
  import { orderStatusMappings, fromApiStatusToOrderStatus } from '../model/storefront.model.js';
4
4
 
5
- async function fetchOrders({ page = 1, pageSize = 20, search, sort, status, } = {}) {
5
+ async function fetchOrders({ customerSequence, page = 1, pageSize = 20, search, sort, status, } = {}) {
6
6
  const searchParams = new URLSearchParams();
7
7
  if (page)
8
8
  searchParams.set('page', page.toString());
@@ -18,9 +18,11 @@ async function fetchOrders({ page = 1, pageSize = 20, search, sort, status, } =
18
18
  searchParams.append('status', mappedStatus);
19
19
  });
20
20
  }
21
+ if (customerSequence)
22
+ searchParams.set('customerSequence', customerSequence);
21
23
  const { body } = await request({
22
24
  credentials: 'include',
23
- url: `${config.SHOP_API_URL}/api/v1/orders/${searchParams.size > 0 ? `?${searchParams.toString()}` : ''}`,
25
+ url: `${config.SHOP_API_URL}/api/v1/orders${searchParams.size > 0 ? `?${searchParams.toString()}` : ''}`,
24
26
  });
25
27
  body.orders?.forEach(order => (order.status = fromApiStatusToOrderStatus(order.status)));
26
28
  return body;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {