@sonic-equipment/ui 229.0.0 → 230.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.
@@ -7,7 +7,9 @@ import { Checkbox } from '../../../../forms/elements/checkbox/checkbox.js';
7
7
  import { TextField } from '../../../../forms/fields/text-field/text-field.js';
8
8
  import { FormattedMessage } from '../../../../intl/formatted-message.js';
9
9
  import { useFormattedMessage } from '../../../../intl/use-formatted-message.js';
10
+ import { useLocation } from '../../../../shared/routing/use-location.js';
10
11
  import { usePaths } from '../../../../shared/routing/use-paths.js';
12
+ import { environment } from '../../../../shared/utils/environment.js';
11
13
  import { CheckoutPageSection } from '../../layouts/checkout-page-layout/components/checkout-page-section.js';
12
14
  import { CheckoutPageSectionContent } from '../../layouts/checkout-page-layout/components/checkout-page-section-content.js';
13
15
  import { CheckoutPageSectionLink } from '../../layouts/checkout-page-layout/components/checkout-page-section-link.js';
@@ -18,6 +20,16 @@ import styles from './readonly-address.module.css.js';
18
20
  function ReadOnlyAddresses({ billTo, isLoading, isPickup, notes, onSubmit, shipTo, }) {
19
21
  const t = useFormattedMessage();
20
22
  const paths = usePaths();
23
+ const { pathname, search } = useLocation();
24
+ const href = `${pathname}${search}`;
25
+ const billToId = billTo?.id;
26
+ const shipToId = shipTo?.id;
27
+ const editBillToAddressUrl = environment === 'next'
28
+ ? `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/${billToId}?returnUrl=${encodeURIComponent(href)}`
29
+ : paths.ACCOUNT_ADDRESSES;
30
+ const editShipToAddressUrl = environment === 'next'
31
+ ? `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/${billToId}${paths.ACCOUNT_EDIT_SHIP_TO_ADDRESS}/${shipToId}?returnUrl=${encodeURIComponent(href)}`
32
+ : paths.ACCOUNT_ADDRESSES;
21
33
  return (jsxs(Form, { id: EDIT_ADDRESS_FORM_ID, onSubmit: e => {
22
34
  e.preventDefault();
23
35
  const formData = new FormData(e.currentTarget);
@@ -26,7 +38,7 @@ function ReadOnlyAddresses({ billTo, isLoading, isPickup, notes, onSubmit, shipT
26
38
  ? undefined
27
39
  : formData.get('notes')?.toString() || '',
28
40
  });
29
- }, children: [jsxs(CheckoutPageSection, { title: jsx(FormattedMessage, { id: "Billing address" }), children: [jsx(CheckoutPageSectionLink, { children: jsxs(Link, { color: "secondary", href: paths.ACCOUNT_ADDRESSES, isDisabled: isLoading, children: [jsx(FormattedMessage, { id: "Edit billing address" }), " >"] }) }), jsxs(CheckoutPageSectionContent, { children: [billTo && (jsx(AddressInfoDisplay, { address: {
41
+ }, children: [jsxs(CheckoutPageSection, { title: jsx(FormattedMessage, { id: "Billing address" }), children: [jsx(CheckoutPageSectionLink, { children: jsxs(Link, { color: "secondary", href: editBillToAddressUrl, isDisabled: isLoading, children: [jsx(FormattedMessage, { id: "Edit billing address" }), " >"] }) }), jsxs(CheckoutPageSectionContent, { children: [billTo && (jsx(AddressInfoDisplay, { address: {
30
42
  address1: billTo.address1,
31
43
  address2: billTo.address2,
32
44
  address3: billTo.address3,
@@ -39,7 +51,7 @@ function ReadOnlyAddresses({ billTo, isLoading, isPickup, notes, onSubmit, shipT
39
51
  lastName: billTo.lastName,
40
52
  phone: billTo.phone,
41
53
  postalCode: billTo.postalCode,
42
- }, "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 }) })] })] }), jsxs(CheckoutPageSection, { title: jsx(FormattedMessage, { id: isPickup ? 'Pickup address' : 'Shipping address' }), children: [!isPickup && (jsx(CheckoutPageSectionLink, { children: jsxs(Link, { color: "secondary", href: paths.ACCOUNT_ADDRESSES, isDisabled: isLoading, children: [jsx(FormattedMessage, { id: "Edit shipping address" }), " >"] }) })), jsx(CheckoutPageSectionContent, { children: isPickup ? (jsx(SonicAddress, {})) : (jsxs(Fragment, { children: [jsx(Checkbox, { className: styles['use-invoice-checkbox'], "data-test-selector": "checkboxUseBillingAddress", isDisabled: true, isSelected: true, children: jsx(FormattedMessage, { id: "Use billing address" }) }), shipTo && (jsx(AddressInfoDisplay, { address: {
54
+ }, "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 }) })] })] }), jsxs(CheckoutPageSection, { title: jsx(FormattedMessage, { id: isPickup ? 'Pickup address' : 'Shipping address' }), children: [!isPickup && (jsx(CheckoutPageSectionLink, { children: jsxs(Link, { color: "secondary", href: editShipToAddressUrl, isDisabled: isLoading, children: [jsx(FormattedMessage, { id: "Edit shipping address" }), " >"] }) })), jsx(CheckoutPageSectionContent, { children: isPickup ? (jsx(SonicAddress, {})) : (jsxs(Fragment, { children: [jsx(Checkbox, { className: styles['use-invoice-checkbox'], "data-test-selector": "checkboxUseBillingAddress", isDisabled: true, isSelected: true, children: jsx(FormattedMessage, { id: "Use billing address" }) }), shipTo && (jsx(AddressInfoDisplay, { address: {
43
55
  address1: shipTo.address1,
44
56
  address2: shipTo.address2,
45
57
  address3: shipTo.address3,
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { useQueryClient, useMutation } from '@tanstack/react-query';
3
+ import { UnprocessableContentRequestError } from '../../../../fetch/request.js';
3
4
  import { signIn, createSession, InvalidGrantError } from '../../services/authentication-service.js';
4
5
 
5
6
  function useSignIn() {
@@ -18,6 +19,8 @@ function useSignIn() {
18
19
  return body;
19
20
  }
20
21
  catch (error) {
22
+ if (error instanceof UnprocessableContentRequestError)
23
+ throw error;
21
24
  if (error instanceof InvalidGrantError)
22
25
  throw error;
23
26
  queryClient.resetQueries();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "229.0.0",
3
+ "version": "230.0.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {