@sonic-equipment/ui 1.1.4 → 1.1.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.
- package/dist/algolia/algolia-search-provider.js +24 -2
- package/dist/pages/checkout/shipping-page/components/address-book-selector.js +1 -1
- package/dist/pages/checkout/shipping-page/components/readonly-address.d.ts +1 -2
- package/dist/pages/checkout/shipping-page/components/readonly-address.js +3 -4
- package/dist/pages/checkout/shipping-page/components/ship-to-mode-selector.js +1 -1
- package/dist/pages/checkout/shipping-page/shipping-page.js +1 -1
- package/dist/pages/my-sonic/actions/create-ship-to-address/connected-create-ship-to-address-form.js +1 -1
- package/dist/pages/my-sonic/actions/edit-ship-to-address/connected-edit-ship-to-address-form.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { createContext, useState,
|
|
3
|
+
import { createContext, useState, useRef, useEffect, useMemo } from 'react';
|
|
4
4
|
import { config } from '../config.js';
|
|
5
5
|
import { categoriesPlugin } from '../global-search/plugins/categories-plugin.js';
|
|
6
6
|
import { popularCategoriesPlugin } from '../global-search/plugins/popular-categories-plugin.js';
|
|
@@ -30,6 +30,23 @@ function AlgoliaSearchProvider({ children, searchClient: _searchClient, }) {
|
|
|
30
30
|
query: '',
|
|
31
31
|
status: 'idle',
|
|
32
32
|
});
|
|
33
|
+
// `createAutocomplete` is instantiated in a `useMemo` below, and its
|
|
34
|
+
// plugins (notably the Algolia insights plugin) can synchronously kick
|
|
35
|
+
// off `onStateChange` before the component has committed/mounted — e.g.
|
|
36
|
+
// when `window.aa`'s insights queue already resolved from a prior render
|
|
37
|
+
// (React Strict Mode's double-invoke, or a Fast Refresh remount). Calling
|
|
38
|
+
// `setState` at that point trips React's "state update on a component
|
|
39
|
+
// that hasn't mounted yet" warning. Buffer any pre-mount update and flush
|
|
40
|
+
// it once mounted instead of calling `setState` directly from render.
|
|
41
|
+
const isMountedRef = useRef(false);
|
|
42
|
+
const pendingStateRef = useRef(null);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
isMountedRef.current = true;
|
|
45
|
+
if (pendingStateRef.current) {
|
|
46
|
+
setState(pendingStateRef.current);
|
|
47
|
+
pendingStateRef.current = null;
|
|
48
|
+
}
|
|
49
|
+
}, []);
|
|
33
50
|
const searchClient = useMemo(() => _searchClient ||
|
|
34
51
|
createSonicSearchClient({
|
|
35
52
|
apiKey: config.ALGOLIA_API_KEY,
|
|
@@ -86,7 +103,12 @@ function AlgoliaSearchProvider({ children, searchClient: _searchClient, }) {
|
|
|
86
103
|
getSources,
|
|
87
104
|
insights: true,
|
|
88
105
|
onStateChange({ state }) {
|
|
89
|
-
|
|
106
|
+
if (isMountedRef.current) {
|
|
107
|
+
setState(state);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
pendingStateRef.current = state;
|
|
111
|
+
}
|
|
90
112
|
},
|
|
91
113
|
openOnFocus: true,
|
|
92
114
|
plugins: [
|
|
@@ -63,7 +63,7 @@ className, currentShipToId, }) {
|
|
|
63
63
|
Math.random().toString(36).slice(2, 15) + currentShipToId,
|
|
64
64
|
];
|
|
65
65
|
}, [data?.shipTos, error, hasMoreResults, t, currentShipToId]);
|
|
66
|
-
return (jsxs("div", { className: clsx(styles['address-book-selector-container'], className), children: [jsx(SearchField, { autoFocus: true, isDebounced: true, "aria-controls": "filtered-address-results-list", isDisabled: isFetching, isLoading: isFetching, label: t('Search addresses'), onChange: setSearch, onKeyUp: ({ key }) => {
|
|
66
|
+
return (jsxs("div", { className: clsx(styles['address-book-selector-container'], className), children: [jsx(SearchField, { autoFocus: true, isDebounced: true, "aria-controls": "filtered-address-results-list", "data-test-selector": "search-shipping-adress-field", isDisabled: isFetching, isLoading: isFetching, label: t('Search addresses'), onChange: setSearch, onKeyUp: ({ key }) => {
|
|
67
67
|
if (key === 'ArrowDown') {
|
|
68
68
|
listBoxRef.current?.focus();
|
|
69
69
|
}
|
|
@@ -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,
|
|
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
|
|
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,
|
|
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, {})) :
|
|
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'
|
|
@@ -19,7 +19,7 @@ function ShipToModeSelector(props) {
|
|
|
19
19
|
// useDefaultShipTo: props.shipToInfoDisplay,
|
|
20
20
|
useNewAddress: props.newAddressForm,
|
|
21
21
|
}[shippingOption];
|
|
22
|
-
return (jsxs(Fragment, { children: [jsx(SelectField, { "data-test-selector": "
|
|
22
|
+
return (jsxs(Fragment, { children: [jsx(SelectField, { "data-test-selector": "select-shipping-adress", label: t('Shipping address'), name: "shippingType", onChange: setShippingOption, options: options, selectedOption: shippingOption, showLabel: false }), additionalComponentForShipping] }));
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export { ShipToModeSelector as default };
|
|
@@ -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,
|
|
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 ||
|
package/dist/pages/my-sonic/actions/create-ship-to-address/connected-create-ship-to-address-form.js
CHANGED
|
@@ -83,7 +83,7 @@ function ConnectedCreateShipToAddressForm({ billToId, makeDefault, 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, { 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" }) })] })] }));
|
|
86
|
+
}, children: [jsx(AddressForm, { address: undefined, countries: countries, currentCountry: currentCountry, isLoading: isPatching }), jsx(Checkbox, { "data-test-selector": "makeDefaultShippingAddress", 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 };
|
package/dist/pages/my-sonic/actions/edit-ship-to-address/connected-edit-ship-to-address-form.js
CHANGED
|
@@ -123,7 +123,7 @@ function ConnectedEditShipToAddressForm({ billToId, returnUrl, shipToId, }) {
|
|
|
123
123
|
},
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
|
-
}, children: [jsx(AddressForm, { address: shipToAddress, countries: countries, currentCountry: currentCountry, isLoading: isPatching, isReadonly: isReadonly || isPatching }), shipToAddress.id !== 'current' && (jsxs(Fragment, { children: [jsx(Checkbox, { defaultSelected: shipToAddress.isDefault, isDisabled: isReadonly || isPatching || hasCartItems, name: "setAsDefault", value: "TRUE", children: jsx(FormattedMessage, { id: "Make this the default ship to address" }) }), hasCartItems && (jsx("div", { className: styles.info, children: jsx(Message, { type: "info", children: jsx(FormattedMessage, { id: "You cannot change the default ship to address while there are items in your cart." }) }) }))] })), isSuccess && !isPatching && (jsx("div", { className: styles.info, children: jsx(Message, { type: "success", 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" }) })), !isReadonly && (jsx(Button, { isLoading: isPatching ? jsx(FormattedMessage, { id: "Saving" }) : undefined, type: "submit", children: jsx(FormattedMessage, { id: "Save" }) }))] })] }));
|
|
126
|
+
}, children: [jsx(AddressForm, { address: shipToAddress, countries: countries, currentCountry: currentCountry, isLoading: isPatching, isReadonly: isReadonly || isPatching }), shipToAddress.id !== 'current' && (jsxs(Fragment, { children: [jsx(Checkbox, { "data-test-selector": "makeDefaultShippingAddress", defaultSelected: shipToAddress.isDefault, isDisabled: isReadonly || isPatching || hasCartItems, name: "setAsDefault", value: "TRUE", children: jsx(FormattedMessage, { id: "Make this the default ship to address" }) }), hasCartItems && (jsx("div", { className: styles.info, children: jsx(Message, { type: "info", children: jsx(FormattedMessage, { id: "You cannot change the default ship to address while there are items in your cart." }) }) }))] })), isSuccess && !isPatching && (jsx("div", { className: styles.info, children: jsx(Message, { type: "success", 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" }) })), !isReadonly && (jsx(Button, { isLoading: isPatching ? jsx(FormattedMessage, { id: "Saving" }) : undefined, type: "submit", children: jsx(FormattedMessage, { id: "Save" }) }))] })] }));
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
export { ConnectedEditShipToAddressForm };
|