@sonic-equipment/ui 184.0.0 → 186.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/address-info-display/address-info-display.d.ts +2 -2
- package/dist/address-info-display/address-info-display.js +1 -1
- package/dist/algolia/algolia-multi-select-filter-section.js +1 -1
- package/dist/algolia/algolia-sort-by.js +1 -1
- package/dist/buttons/add-to-cart-button/add-to-cart-button.js +1 -1
- package/dist/cards/data-card/data-card.js +37 -20
- package/dist/cards/data-card/data-card.module.css.js +1 -1
- package/dist/country-select/country-select.js +1 -1
- package/dist/country-select/hooks/use-countries.js +1 -0
- package/dist/country-selector/country-selector-dialog/country-selector-dialog.js +2 -6
- package/dist/exports.d.ts +43 -23
- package/dist/filters/pagination/pagination.js +1 -1
- package/dist/forms/elements/checkbox/checkbox.module.css.js +3 -0
- package/dist/forms/{field-error → elements/field-error}/field-error.js +1 -1
- package/dist/forms/elements/field-error/field-error.module.css.js +3 -0
- package/dist/forms/elements/input/input.module.css.js +3 -0
- package/dist/forms/elements/label/label.module.css.js +3 -0
- package/dist/forms/{select → elements/select}/select.d.ts +2 -1
- package/dist/forms/{select → elements/select}/select.js +5 -5
- package/dist/forms/elements/select/select.module.css.js +3 -0
- package/dist/forms/elements/switch/switch.module.css.js +3 -0
- package/dist/forms/elements/textarea/textarea.module.css.js +3 -0
- package/dist/forms/{checkbox-field → fields/checkbox-field}/checkbox-field.d.ts +2 -2
- package/dist/forms/{checkbox-field → fields/checkbox-field}/checkbox-field.js +4 -4
- package/dist/forms/fields/checkbox-field/checkbox-field.module.css.js +3 -0
- package/dist/forms/{number-field → fields/number-field}/number-field.d.ts +1 -1
- package/dist/forms/{number-field → fields/number-field}/number-field.js +8 -8
- package/dist/forms/fields/number-field/number-field.module.css.js +3 -0
- package/dist/forms/{search-field → fields/search-field}/search-field.js +3 -3
- package/dist/forms/{select-field → fields/select-field}/select-field.d.ts +1 -1
- package/dist/forms/{select-field → fields/select-field}/select-field.js +7 -7
- package/dist/forms/fields/select-field/select-field.module.css.js +3 -0
- package/dist/forms/{switch-field → fields/switch-field}/switch-field.d.ts +2 -2
- package/dist/forms/{switch-field → fields/switch-field}/switch-field.js +4 -4
- package/dist/forms/fields/switch-field/switch-field.module.css.js +3 -0
- package/dist/forms/{text-field → fields/text-field}/password-reveal-toggle/password-reveal-toggle.js +3 -3
- package/dist/forms/{text-field → fields/text-field}/password-reveal-toggle/password-reveal-toggle.module.css.js +1 -1
- package/dist/forms/{text-field → fields/text-field}/text-field.d.ts +1 -1
- package/dist/forms/{text-field → fields/text-field}/text-field.js +6 -6
- package/dist/forms/fields/text-field/text-field.module.css.js +3 -0
- package/dist/forms/layout/form/form-field-layout.module.css.js +3 -0
- package/dist/forms/layout/form/form-segment-group.module.css.js +3 -0
- package/dist/forms/layout/form/form-segment.module.css.js +3 -0
- package/dist/forms/layout/form/form.d.ts +20 -0
- package/dist/forms/{form → layout/form}/form.js +4 -4
- package/dist/forms/layout/form/form.module.css.js +3 -0
- package/dist/forms/partials/edit-address-form/edit-address-form.d.ts +8 -0
- package/dist/forms/partials/edit-address-form/edit-address-form.js +35 -0
- package/dist/forms/partials/edit-address-form/edit-address-form.module.css.js +3 -0
- package/dist/forms/partials/password-validation/password-validation.d.ts +4 -0
- package/dist/forms/partials/password-validation/password-validation.js +32 -0
- package/dist/index.js +44 -24
- package/dist/intl/formatted-message.js +5 -1
- package/dist/intl/translation-id.d.ts +1 -1
- package/dist/intl/types.d.ts +6 -1
- package/dist/intl/use-formatted-message.js +2 -1
- package/dist/lists/menu-list/menu-list.d.ts +2 -1
- package/dist/lists/menu-list/menu-list.js +2 -2
- package/dist/lists/widget-grid/widget-grid.d.ts +5 -0
- package/dist/lists/widget-grid/widget-grid.js +9 -0
- package/dist/lists/widget-grid/widget-grid.module.css.js +3 -0
- package/dist/lists/widget-grid/widget.d.ts +6 -0
- package/dist/lists/widget-grid/widget.js +10 -0
- package/dist/modals/dialog/dialog.d.ts +5 -5
- package/dist/modals/dialog/dialog.js +18 -18
- package/dist/modals/dialog/dialog.module.css.js +1 -1
- package/dist/modals/favorite/add-to-favorite-dialog.js +2 -2
- package/dist/modals/recover-password/recover-password-dialog.js +2 -4
- package/dist/pages/account/components/create-account-form/create-account-form.js +8 -23
- package/dist/pages/account/components/sign-in-form/sign-in-form.js +6 -6
- package/dist/pages/account/create-account-page/create-account-page.js +4 -5
- package/dist/pages/account/layouts/sign-in-page-layout/sign-in-page-layout.js +1 -1
- package/dist/pages/account/sign-in-page/sign-in-page.js +2 -3
- package/dist/pages/checkout/components/billing-and-invoice-information.d.ts +3 -3
- package/dist/pages/checkout/components/billing-and-invoice-information.js +1 -1
- package/dist/pages/checkout/order-confirmation-page/order-confirmation-page-content.js +26 -20
- package/dist/pages/checkout/payment-page/components/payment.js +29 -23
- package/dist/pages/checkout/shipping-page/components/{edit-address-form.d.ts → edit-checkout-bill-to-address-form.d.ts} +3 -17
- package/dist/pages/checkout/shipping-page/components/edit-checkout-bill-to-address-form.js +49 -0
- package/dist/pages/checkout/shipping-page/components/edit-checkout-bill-to-address-form.module.css.js +3 -0
- package/dist/pages/checkout/shipping-page/components/readonly-address.js +7 -5
- package/dist/pages/checkout/shipping-page/hooks/use-patch-shipping-details.d.ts +1 -0
- package/dist/pages/checkout/shipping-page/shipping-page-content.js +2 -2
- package/dist/pages/checkout/shipping-page/shipping-page.js +2 -2
- package/dist/pages/components/page-container/page-container.js +1 -1
- package/dist/pages/my-sonic/actions/change-customer/change-customer-dialog.d.ts +4 -3
- package/dist/pages/my-sonic/actions/change-customer/change-customer-dialog.js +10 -4
- package/dist/pages/my-sonic/actions/change-customer/change-customer.d.ts +5 -2
- package/dist/pages/my-sonic/actions/change-customer/change-customer.js +17 -8
- package/dist/pages/my-sonic/actions/change-customer/change-customer.module.css.js +1 -1
- package/dist/pages/my-sonic/actions/change-customer/connected-change-customer-dialog.d.ts +7 -2
- package/dist/pages/my-sonic/actions/change-customer/connected-change-customer-dialog.js +9 -6
- package/dist/pages/my-sonic/actions/change-password/change-password-dialog.d.ts +10 -0
- package/dist/pages/my-sonic/actions/change-password/change-password-dialog.js +24 -0
- package/dist/pages/my-sonic/actions/change-password/change-password.d.ts +7 -0
- package/dist/pages/my-sonic/actions/change-password/change-password.js +35 -0
- package/dist/pages/my-sonic/actions/change-password/change-password.module.css.js +3 -0
- package/dist/pages/my-sonic/actions/change-password/connected-change-password-dialog.d.ts +5 -0
- package/dist/pages/my-sonic/actions/change-password/connected-change-password-dialog.js +39 -0
- package/dist/pages/my-sonic/actions/edit-bill-to-address/edit-bill-to-address.d.ts +1 -0
- package/dist/pages/my-sonic/actions/edit-bill-to-address/edit-bill-to-address.js +8 -0
- package/dist/pages/my-sonic/actions/edit-user-info/connected-edit-user-info-dialog.d.ts +5 -0
- package/dist/pages/my-sonic/actions/edit-user-info/connected-edit-user-info-dialog.js +56 -0
- package/dist/pages/my-sonic/actions/edit-user-info/edit-user-info-dialog.d.ts +10 -0
- package/dist/pages/my-sonic/actions/edit-user-info/edit-user-info-dialog.js +15 -0
- package/dist/pages/my-sonic/actions/edit-user-info/edit-user-info.d.ts +11 -0
- package/dist/pages/my-sonic/actions/edit-user-info/edit-user-info.js +29 -0
- package/dist/pages/my-sonic/actions/edit-user-info/edit-user-info.module.css.js +3 -0
- package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-aside.d.ts +4 -0
- package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-aside.js +9 -0
- package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-main.d.ts +4 -0
- package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-main.js +9 -0
- package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-page.d.ts +5 -0
- package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-page.js +10 -0
- package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-pre-aside.d.ts +4 -0
- package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-pre-aside.js +9 -0
- package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-title.d.ts +4 -0
- package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-title.js +10 -0
- package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout.d.ts +5 -0
- package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout.js +10 -0
- package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout.module.css.js +3 -0
- package/dist/pages/my-sonic/navigation/connected-my-sonic-navigation.js +3 -4
- package/dist/pages/my-sonic/navigation/connected-my-sonic-navigation.module.css.js +3 -0
- package/dist/pages/my-sonic/navigation/my-sonic-desktop-navigation.d.ts +2 -1
- package/dist/pages/my-sonic/navigation/my-sonic-desktop-navigation.js +2 -2
- package/dist/pages/my-sonic/navigation/my-sonic-mobile-navigation.d.ts +2 -1
- package/dist/pages/my-sonic/navigation/my-sonic-mobile-navigation.js +3 -3
- package/dist/pages/my-sonic/widgets/connected-customer-information-widget.js +3 -3
- package/dist/pages/my-sonic/widgets/connected-user-account-widget.js +16 -5
- package/dist/shared/api/shared/hooks/use-awaitable-mutation.d.ts +1 -0
- package/dist/shared/api/shared/hooks/use-awaitable-mutation.js +6 -0
- package/dist/shared/api/storefront/hooks/{authentication → account}/use-create-account.d.ts +1 -1
- package/dist/shared/api/storefront/hooks/{authentication → account}/use-create-account.js +3 -1
- package/dist/shared/api/storefront/hooks/{authentication → account}/use-create-guest-account.js +3 -1
- package/dist/shared/api/storefront/hooks/account/use-fetch-current-account.d.ts +3 -0
- package/dist/shared/api/storefront/hooks/account/use-fetch-current-account.js +13 -0
- package/dist/shared/api/storefront/hooks/account/use-patch-current-account.d.ts +11 -0
- package/dist/shared/api/storefront/hooks/account/use-patch-current-account.js +20 -0
- package/dist/shared/api/storefront/hooks/authentication/use-patch-session.d.ts +1 -0
- package/dist/shared/api/storefront/hooks/authentication/use-patch-session.js +1 -1
- package/dist/shared/api/storefront/hooks/cart/use-patch-cart.d.ts +1 -0
- package/dist/shared/api/storefront/hooks/cart/use-place-order.d.ts +1 -0
- package/dist/shared/api/storefront/hooks/customer/use-patch-bill-to-address.d.ts +1 -0
- package/dist/shared/api/storefront/services/account-service.d.ts +31 -0
- package/dist/shared/api/storefront/services/account-service.js +84 -0
- package/dist/shared/api/storefront/services/authentication-service.d.ts +7 -26
- package/dist/shared/api/storefront/services/authentication-service.js +38 -65
- package/dist/shared/data/countries-languages.data.js +4 -0
- package/dist/shared/model/address.d.ts +27 -12
- package/dist/shared/model/countries-languages.d.ts +1 -0
- package/dist/shared/utils/price.d.ts +1 -1
- package/dist/styles.css +751 -627
- package/package.json +1 -1
- package/dist/forms/checkbox/checkbox.module.css.js +0 -3
- package/dist/forms/checkbox-field/checkbox-field.module.css.js +0 -3
- package/dist/forms/field-error/field-error.module.css.js +0 -3
- package/dist/forms/form/form-field-layout.module.css.js +0 -3
- package/dist/forms/form/form-segment-group.module.css.js +0 -3
- package/dist/forms/form/form-segment.module.css.js +0 -3
- package/dist/forms/form/form.d.ts +0 -16
- package/dist/forms/form/form.module.css.js +0 -3
- package/dist/forms/input/input.module.css.js +0 -3
- package/dist/forms/label/label.module.css.js +0 -3
- package/dist/forms/number-field/number-field.module.css.js +0 -3
- package/dist/forms/select/select.module.css.js +0 -3
- package/dist/forms/select-field/select-field.module.css.js +0 -3
- package/dist/forms/switch/switch.module.css.js +0 -3
- package/dist/forms/switch-field/switch-field.module.css.js +0 -3
- package/dist/forms/text-field/text-field.module.css.js +0 -3
- package/dist/forms/textarea/textarea.module.css.js +0 -3
- package/dist/pages/checkout/shipping-page/components/edit-address-form.js +0 -68
- package/dist/pages/checkout/shipping-page/components/edit-address-form.module.css.js +0 -3
- /package/dist/forms/{checkbox → elements/checkbox}/checkbox.d.ts +0 -0
- /package/dist/forms/{checkbox → elements/checkbox}/checkbox.js +0 -0
- /package/dist/forms/{color-checkbox → elements/color-checkbox}/color-checkbox.d.ts +0 -0
- /package/dist/forms/{color-checkbox → elements/color-checkbox}/color-checkbox.js +0 -0
- /package/dist/forms/{field-error → elements/field-error}/field-error.d.ts +0 -0
- /package/dist/forms/{input → elements/input}/input.d.ts +0 -0
- /package/dist/forms/{input → elements/input}/input.js +0 -0
- /package/dist/forms/{label → elements/label}/label.d.ts +0 -0
- /package/dist/forms/{label → elements/label}/label.js +0 -0
- /package/dist/forms/{switch → elements/switch}/switch.d.ts +0 -0
- /package/dist/forms/{switch → elements/switch}/switch.js +0 -0
- /package/dist/forms/{textarea → elements/textarea}/textarea.d.ts +0 -0
- /package/dist/forms/{textarea → elements/textarea}/textarea.js +0 -0
- /package/dist/forms/{password-field → fields/password-field}/password-field.d.ts +0 -0
- /package/dist/forms/{password-field → fields/password-field}/password-field.js +0 -0
- /package/dist/forms/{search-field → fields/search-field}/search-field.d.ts +0 -0
- /package/dist/forms/{text-field → fields/text-field}/password-reveal-toggle/password-reveal-toggle.d.ts +0 -0
- /package/dist/forms/{form → layout/form}/form-field-layout.d.ts +0 -0
- /package/dist/forms/{form → layout/form}/form-field-layout.js +0 -0
- /package/dist/forms/{form → layout/form}/form-segment-group.d.ts +0 -0
- /package/dist/forms/{form → layout/form}/form-segment-group.js +0 -0
- /package/dist/forms/{form → layout/form}/form-segment.d.ts +0 -0
- /package/dist/forms/{form → layout/form}/form-segment.js +0 -0
- /package/dist/shared/api/storefront/hooks/{authentication → account}/use-create-guest-account.d.ts +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { useEffect } from 'react';
|
|
4
4
|
import { Button } from '../../buttons/button/button.js';
|
|
5
|
-
import { TextField } from '../../forms/text-field/text-field.js';
|
|
5
|
+
import { TextField } from '../../forms/fields/text-field/text-field.js';
|
|
6
6
|
import { useFormattedMessage } from '../../intl/use-formatted-message.js';
|
|
7
7
|
import { Message } from '../../message/message.js';
|
|
8
8
|
import { useRecoverPassword } from '../../shared/api/storefront/hooks/authentication/use-recover-password.js';
|
|
@@ -17,9 +17,7 @@ function RecoverPasswordDialog({ isOpen, onOpenChange, }) {
|
|
|
17
17
|
reset();
|
|
18
18
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
19
|
}, [isOpen]);
|
|
20
|
-
const onSubmit = (
|
|
21
|
-
const form = event.currentTarget;
|
|
22
|
-
const formData = new FormData(form);
|
|
20
|
+
const onSubmit = ({ formData }) => {
|
|
23
21
|
const email = formData.get('email')?.toString();
|
|
24
22
|
if (!email)
|
|
25
23
|
throw new Error('Email value is required');
|
|
@@ -4,15 +4,14 @@ import { useState } from 'react';
|
|
|
4
4
|
import { Button } from '../../../../buttons/button/button.js';
|
|
5
5
|
import { CountrySelect } from '../../../../country-select/country-select.js';
|
|
6
6
|
import { useCountries } from '../../../../country-select/hooks/use-countries.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
7
|
+
import { SwitchField } from '../../../../forms/fields/switch-field/switch-field.js';
|
|
8
|
+
import { TextField } from '../../../../forms/fields/text-field/text-field.js';
|
|
9
|
+
import { Form } from '../../../../forms/layout/form/form.js';
|
|
10
|
+
import { FormSegment } from '../../../../forms/layout/form/form-segment.js';
|
|
11
|
+
import { FormSegmentGroup } from '../../../../forms/layout/form/form-segment-group.js';
|
|
12
|
+
import { PasswordValidation } from '../../../../forms/partials/password-validation/password-validation.js';
|
|
13
13
|
import { isCountryCode } from '../../../../intl/types.js';
|
|
14
14
|
import { useFormattedMessage } from '../../../../intl/use-formatted-message.js';
|
|
15
|
-
import { validatePassword } from '../../../../shared/model/account.js';
|
|
16
15
|
import { validateEmail } from '../../../../shared/model/address.js';
|
|
17
16
|
import { Heading } from '../../../../typography/heading/heading.js';
|
|
18
17
|
import styles from './create-account-form.module.css.js';
|
|
@@ -22,8 +21,6 @@ function CreateAccountForm({ errorType, isDisabled: _isDisabled = false, isPendi
|
|
|
22
21
|
const title = t('create account');
|
|
23
22
|
const isDisabled = isPendingCreateAccount || _isDisabled;
|
|
24
23
|
const [isPrivateAccount, setIsPrivateAccount] = useState(false);
|
|
25
|
-
const [password, setPassword] = useState('');
|
|
26
|
-
const [passwordConfirm, setPasswordConfirm] = useState('');
|
|
27
24
|
const [lastName, setLastName] = useState('');
|
|
28
25
|
const [companyName, setCompanyName] = useState('');
|
|
29
26
|
const errorMessages = {
|
|
@@ -36,7 +33,7 @@ function CreateAccountForm({ errorType, isDisabled: _isDisabled = false, isPendi
|
|
|
36
33
|
const firstName = formData.get('firstName')?.toString();
|
|
37
34
|
const lastName = formData.get('lastName')?.toString() || '';
|
|
38
35
|
const email = formData.get('email')?.toString();
|
|
39
|
-
const password = formData.get('password')?.toString();
|
|
36
|
+
const password = formData.get('new-password')?.toString();
|
|
40
37
|
const isSubscribed = Boolean(formData.get('isSubscribed'));
|
|
41
38
|
const isPrivateAccount = Boolean(formData.get('isPrivateAccount'));
|
|
42
39
|
const countryId = formData.get('countrySelect')?.toString();
|
|
@@ -64,13 +61,6 @@ function CreateAccountForm({ errorType, isDisabled: _isDisabled = false, isPendi
|
|
|
64
61
|
},
|
|
65
62
|
});
|
|
66
63
|
};
|
|
67
|
-
const isMismatchingPasswords = () => {
|
|
68
|
-
if (!passwordConfirm)
|
|
69
|
-
return;
|
|
70
|
-
if (passwordConfirm === password)
|
|
71
|
-
return false;
|
|
72
|
-
return true;
|
|
73
|
-
};
|
|
74
64
|
// form header
|
|
75
65
|
const header = (jsx(Heading, { "data-test-selector": "PageTitle", italic: true, size: "m", tag: "h1", uppercase: true, children: title }));
|
|
76
66
|
// form footer
|
|
@@ -79,12 +69,7 @@ function CreateAccountForm({ errorType, isDisabled: _isDisabled = false, isPendi
|
|
|
79
69
|
if (!value)
|
|
80
70
|
return value;
|
|
81
71
|
return (validateEmail(value) || t('Please enter a valid email address'));
|
|
82
|
-
} }) }), jsx(FormSegment, { children: jsx(
|
|
83
|
-
if (!value)
|
|
84
|
-
return;
|
|
85
|
-
return (validatePassword(value) ||
|
|
86
|
-
t('Password does not meet requirements'));
|
|
87
|
-
} }) }), jsx(FormSegment, { children: jsx(PasswordField, { autoComplete: "new-password", customErrorMessage: "Passwords do not match", "data-test-selector": "createAccount_passwordConfirm", isDisabled: isDisabled, isInvalid: isMismatchingPasswords(), isRequired: true, label: t('Confirm password'), onChange: setPasswordConfirm, value: passwordConfirm }) })] }), jsxs(FormSegmentGroup, { children: [jsx(FormSegment, { children: jsx(SwitchField, { isDisabled: isDisabled, isSelected: isPrivateAccount, name: "isPrivateAccount", onChange: setIsPrivateAccount, children: t('Private account') }) }), jsx(FormSegment, { children: jsx(TextField, { autoComplete: "organization", "data-test-selector": "createAccount_companyName", isDisabled: isDisabled, isRequired: !isPrivateAccount, label: t('Company name'), name: "companyName", onChange: setCompanyName, value: companyName }, `companyName-${Boolean(isPrivateAccount)}`) }), jsx(FormSegment, { children: jsx(TextField, { autoComplete: "given-name", "data-test-selector": "createAccount_firstName", isDisabled: isDisabled, label: t('First name'), name: "firstName" }) }), jsx(FormSegment, { children: jsx(TextField, { autoComplete: "family-name", "data-test-selector": "createAccount_lastName", isDisabled: isDisabled, isRequired: isPrivateAccount, label: t('Last name'), name: "lastName", onChange: setLastName, value: lastName }, `lastname-${Boolean(isPrivateAccount)}`) }), jsx(FormSegment, { children: jsx(CountrySelect, { isRequired: true, countries: countries || [], "data-test-selector": "createAccount_countrySelect", defaultSelectedCountry: defaultSelectedCountry, isDisabled: isLoadingCountries || isDisabled, isLoading: isLoadingCountries, name: "countrySelect" }, defaultSelectedCountry?.id) })] }), jsx(FormSegmentGroup, { children: jsx(FormSegment, { children: jsx(SwitchField, { isDisabled: isDisabled, name: "isSubscribed", children: t('Sign me up for newsletters and product updates') }) }) })] }));
|
|
72
|
+
} }) }), jsx(PasswordValidation, { isDisabled: isDisabled })] }), jsxs(FormSegmentGroup, { children: [jsx(FormSegment, { children: jsx(SwitchField, { isDisabled: isDisabled, isSelected: isPrivateAccount, name: "isPrivateAccount", onChange: setIsPrivateAccount, children: t('Private account') }) }), jsx(FormSegment, { children: jsx(TextField, { autoComplete: "organization", "data-test-selector": "createAccount_companyName", isDisabled: isDisabled, isRequired: !isPrivateAccount, label: t('Company name'), name: "companyName", onChange: setCompanyName, value: companyName }, `companyName-${Boolean(isPrivateAccount)}`) }), jsx(FormSegment, { children: jsx(TextField, { autoComplete: "given-name", "data-test-selector": "createAccount_firstName", isDisabled: isDisabled, label: t('First name'), name: "firstName" }) }), jsx(FormSegment, { children: jsx(TextField, { autoComplete: "family-name", "data-test-selector": "createAccount_lastName", isDisabled: isDisabled, isRequired: isPrivateAccount, label: t('Last name'), name: "lastName", onChange: setLastName, value: lastName }, `lastname-${Boolean(isPrivateAccount)}`) }), jsx(FormSegment, { children: jsx(CountrySelect, { isRequired: true, countries: countries || [], "data-test-selector": "createAccount_countrySelect", defaultSelectedCountry: defaultSelectedCountry, isDisabled: isLoadingCountries || isDisabled, isLoading: isLoadingCountries, name: "countrySelect" }, defaultSelectedCountry?.id) })] }), jsx(FormSegmentGroup, { children: jsx(FormSegment, { children: jsx(SwitchField, { isDisabled: isDisabled, name: "isSubscribed", children: t('Sign me up for newsletters and product updates') }) }) })] }));
|
|
88
73
|
}
|
|
89
74
|
|
|
90
75
|
export { CreateAccountForm };
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { Button } from '../../../../buttons/button/button.js';
|
|
4
4
|
import { Link } from '../../../../buttons/link/link.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
5
|
+
import { PasswordField } from '../../../../forms/fields/password-field/password-field.js';
|
|
6
|
+
import { SwitchField } from '../../../../forms/fields/switch-field/switch-field.js';
|
|
7
|
+
import { TextField } from '../../../../forms/fields/text-field/text-field.js';
|
|
8
|
+
import { Form } from '../../../../forms/layout/form/form.js';
|
|
9
|
+
import { FormSegment } from '../../../../forms/layout/form/form-segment.js';
|
|
10
|
+
import { FormSegmentGroup } from '../../../../forms/layout/form/form-segment-group.js';
|
|
11
11
|
import { useFormattedMessage } from '../../../../intl/use-formatted-message.js';
|
|
12
12
|
import { validateEmail } from '../../../../shared/model/address.js';
|
|
13
13
|
import { voidFunction } from '../../../../shared/model/defaults.js';
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import { Button } from '../../../buttons/button/button.js';
|
|
5
5
|
import { FormattedMessage } from '../../../intl/formatted-message.js';
|
|
6
6
|
import { Dialog } from '../../../modals/dialog/dialog.js';
|
|
7
|
-
import { useCreateAccount } from '../../../shared/api/storefront/hooks/
|
|
7
|
+
import { useCreateAccount } from '../../../shared/api/storefront/hooks/account/use-create-account.js';
|
|
8
8
|
import { useFetchSession } from '../../../shared/api/storefront/hooks/authentication/use-fetch-session.js';
|
|
9
|
-
import { ExistingAccountError } from '../../../shared/api/storefront/services/
|
|
9
|
+
import { ExistingAccountError } from '../../../shared/api/storefront/services/account-service.js';
|
|
10
10
|
import { useNavigate } from '../../../shared/routing/use-navigate.js';
|
|
11
|
-
import { Page } from '../../components/page/page.js';
|
|
12
11
|
import { LoadingPage } from '../../loading-page/loading-page.js';
|
|
13
12
|
import { PATHS } from '../../paths.js';
|
|
14
13
|
import { CreateAccountForm } from '../components/create-account-form/create-account-form.js';
|
|
@@ -40,7 +39,7 @@ function CreateAccountPage({ returnUrl } = {}) {
|
|
|
40
39
|
navigate(continuePath, { reload: true });
|
|
41
40
|
return;
|
|
42
41
|
}
|
|
43
|
-
return (jsxs(
|
|
42
|
+
return (jsxs(Fragment, { children: [jsx(SignInPageLayout, { fullHeight: true, children: jsx(CreateAccountForm, { errorType: errorType, isDisabled: isDisabled, isPendingCreateAccount: isPendingCreateAccount, onSubmit: onSubmit }) }), jsx(Dialog, { footer: jsx(Button, { color: "primary", href: continuePath, route: { reload: true }, size: "md", withArrow: true, children: jsx(FormattedMessage, { id: "Continue" }) }), hasCloseButton: false, isDismissable: false, isKeyboardDismissDisabled: true, isOpen: isSuccess && !isReturnToShipping, title: "Account created", children: jsx("p", { children: jsx(FormattedMessage, { id: "Your new Sonic Equipment account was succesfully created. You should receive an email soon with further instructions on how to activate this account. If you do not receive this email, please contact Customer Support." }) }) }), jsx(Dialog, { footer: jsx(Button, { color: "primary", href: `${PATHS.SIGN_IN}${returnUrl ? `?returnUrl=${continuePath}` : ''}`, route: { reload: true }, size: "md", withArrow: true, children: jsx(FormattedMessage, { id: "Continue to sign in" }) }), hasCloseButton: false, isDismissable: false, isKeyboardDismissDisabled: true, isOpen: isExistingAccount, title: "Existing account", children: jsx("p", { children: jsx(FormattedMessage, { id: "The email address you entered is already associated with an existing account. Please sign in to this account or contact Customer Support." }) }) })] }));
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
export { CreateAccountPage };
|
|
@@ -8,7 +8,7 @@ import styles from './sign-in-page-layout.module.css.js';
|
|
|
8
8
|
|
|
9
9
|
function SignInPageLayout({ children, fullHeight, image = SIGN_IN_PAGE_BACKGROUND_IMAGE, }) {
|
|
10
10
|
const isLg = useIsBreakpoint('lg');
|
|
11
|
-
return (jsxs("div", { className: clsx(styles['sign-in-page-layout'], fullHeight && styles['full-height']), children: [jsx("
|
|
11
|
+
return (jsxs("div", { className: clsx(styles['sign-in-page-layout'], fullHeight && styles['full-height']), children: [jsx("section", { className: styles.main, children: children }), isLg && (jsx("div", { className: styles.side, children: jsx("div", { className: styles.image, children: jsx(Image, { image: image, title: "" }) }) }))] }));
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export { SignInPageLayout };
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useState, useMemo } from 'react';
|
|
4
4
|
import { RecoverPasswordDialog } from '../../../modals/recover-password/recover-password-dialog.js';
|
|
5
|
-
import { useCreateGuestAccount } from '../../../shared/api/storefront/hooks/
|
|
5
|
+
import { useCreateGuestAccount } from '../../../shared/api/storefront/hooks/account/use-create-guest-account.js';
|
|
6
6
|
import { useFetchSession } from '../../../shared/api/storefront/hooks/authentication/use-fetch-session.js';
|
|
7
7
|
import { useSignIn } from '../../../shared/api/storefront/hooks/authentication/use-sign-in.js';
|
|
8
8
|
import { isRequestError } from '../../../shared/fetch/request.js';
|
|
9
9
|
import { useDisclosure } from '../../../shared/hooks/use-disclosure.js';
|
|
10
10
|
import { useNavigate } from '../../../shared/routing/use-navigate.js';
|
|
11
|
-
import { Page } from '../../components/page/page.js';
|
|
12
11
|
import { PATHS } from '../../paths.js';
|
|
13
12
|
import { SignInForm } from '../components/sign-in-form/sign-in-form.js';
|
|
14
13
|
import { SignInPageLayout } from '../layouts/sign-in-page-layout/sign-in-page-layout.js';
|
|
@@ -57,7 +56,7 @@ function SignInPage({ returnUrl } = {}) {
|
|
|
57
56
|
const onRecoverPasswordDialogOpen = () => {
|
|
58
57
|
setRecoverPasswordDialogOpen(true);
|
|
59
58
|
};
|
|
60
|
-
return (jsxs(Fragment, { children: [jsx(
|
|
59
|
+
return (jsxs(Fragment, { children: [jsx(SignInPageLayout, { fullHeight: true, children: jsx(SignInForm, { allowGuestSignIn: allowGuestSignIn, createAccountPath: createAccountPath, errorType: errorType, initialEmail: session?.isGuest ? '' : session?.email, initialRememberMe: session?.rememberMe, isDisabled: !session || isSuccess, isPendingGuestSignIn: isPendingCreateGuest, isPendingUserSignIn: isPendingSignIn, onRecoverPasswordDialogOpen: onRecoverPasswordDialogOpen, onSubmit: onSubmit }) }), jsx(RecoverPasswordDialog, { isOpen: isRecoverPasswordDialogOpen, onOpenChange: isOpen => setRecoverPasswordDialogOpen(isOpen) })] }));
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
export { SignInPage };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Address } from '../../../shared/model/address';
|
|
2
2
|
interface BillingAndInvoiceInformationProps {
|
|
3
|
-
billToAddress:
|
|
4
|
-
shipToAddress:
|
|
3
|
+
billToAddress: Address | undefined | null;
|
|
4
|
+
shipToAddress: Address | undefined | null;
|
|
5
5
|
}
|
|
6
6
|
export declare function BillingAndInvoiceInformation({ billToAddress, shipToAddress, }: BillingAndInvoiceInformationProps): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -7,7 +7,7 @@ import styles from './billing-and-invoice-information.module.css.js';
|
|
|
7
7
|
|
|
8
8
|
function BillingAndInvoiceInformation({ billToAddress, shipToAddress, }) {
|
|
9
9
|
const t = useFormattedMessage();
|
|
10
|
-
return (jsxs("div", { className: styles['billing-and-invoice-information'], children: [jsx("section", { className: styles.section, children: jsx(InfoDisplay, { id: "billing-address", label: t('Billing address'), value: jsx(AddressInfoDisplay, { address: billToAddress, "data-test-selector": "orderConfirmationBillingInformation" }) }) }), jsx("section", { className: styles.section, children: jsx(InfoDisplay, { id: "shipping-address", label: t('Shipping address'), value: jsx(AddressInfoDisplay, { address: shipToAddress, "data-test-selector": "orderConfirmationShippingInformation" }) }) })] }));
|
|
10
|
+
return (jsxs("div", { className: styles['billing-and-invoice-information'], children: [billToAddress && (jsx("section", { className: styles.section, children: jsx(InfoDisplay, { id: "billing-address", label: t('Billing address'), value: jsx(AddressInfoDisplay, { address: billToAddress, "data-test-selector": "orderConfirmationBillingInformation" }) }) })), shipToAddress && (jsx("section", { className: styles.section, children: jsx(InfoDisplay, { id: "shipping-address", label: t('Shipping address'), value: jsx(AddressInfoDisplay, { address: shipToAddress, "data-test-selector": "orderConfirmationShippingInformation" }) }) }))] }));
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export { BillingAndInvoiceInformation };
|
|
@@ -56,26 +56,32 @@ function OrderConfirmationPageContent({ cart, }) {
|
|
|
56
56
|
secondary: (jsxs(Fragment, { children: [cart.canSaveOrder && (jsx(Button, { color: "secondary", onClick: () => {
|
|
57
57
|
saveCartForLater.mutate({ cart });
|
|
58
58
|
}, variant: "outline", children: jsx(FormattedMessage, { id: "Save order" }) })), jsx(PrintButton, {})] })),
|
|
59
|
-
}, overview: jsx(CartTotals, { currencyCode: currencyCode, fulfillmentMethod: cart.fulfillmentMethod, orderNumber: cart.orderNumber, shippingCost: cart.shippingAndHandling, subtotal: cart.orderSubTotal, tax: cart.totalTax, total: cart.orderGrandTotal, vatPercentage: cart.cartLines?.[0]?.pricing?.vatRate }), children: jsxs("div", { children: [jsx(CheckoutPageSection, { hasBorder: false, title: t('General'), children: jsx(CheckoutPageSectionContent, { children: jsxs("div", { className: styles['general-order-info'], children: [cart.orderDate && (jsx(InfoDisplay, { id: "order-date", label: t('Order date'), value: formatDateToLocaleString(new Date(cart.orderDate), cultureCode) })), cart.requestedDeliveryDateDisplay && (jsx(InfoDisplay, { id: "requested-delivery-date", label: t('Requested delivery date'), value: formatDateToLocaleString(new Date(cart.requestedDeliveryDateDisplay.toString()), cultureCode) })), cart.poNumber && (jsx(InfoDisplay, { id: "po-number", label: t('PO Number'), value: cart.poNumber }))] }) }) }), jsx(CheckoutPageSection, { hasBorder: false, title: t('Billing and shipping information'), children: jsx(CheckoutPageSectionContent, { children: jsx(BillingAndInvoiceInformation, { billToAddress: {
|
|
60
|
-
address1: cart.billTo
|
|
61
|
-
address2: cart.billTo
|
|
62
|
-
address3: cart.billTo
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
59
|
+
}, overview: jsx(CartTotals, { currencyCode: currencyCode, fulfillmentMethod: cart.fulfillmentMethod, orderNumber: cart.orderNumber, shippingCost: cart.shippingAndHandling, subtotal: cart.orderSubTotal, tax: cart.totalTax, total: cart.orderGrandTotal, vatPercentage: cart.cartLines?.[0]?.pricing?.vatRate }), children: jsxs("div", { children: [jsx(CheckoutPageSection, { hasBorder: false, title: t('General'), children: jsx(CheckoutPageSectionContent, { children: jsxs("div", { className: styles['general-order-info'], children: [cart.orderDate && (jsx(InfoDisplay, { id: "order-date", label: t('Order date'), value: formatDateToLocaleString(new Date(cart.orderDate), cultureCode) })), cart.requestedDeliveryDateDisplay && (jsx(InfoDisplay, { id: "requested-delivery-date", label: t('Requested delivery date'), value: formatDateToLocaleString(new Date(cart.requestedDeliveryDateDisplay.toString()), cultureCode) })), cart.poNumber && (jsx(InfoDisplay, { id: "po-number", label: t('PO Number'), value: cart.poNumber }))] }) }) }), jsx(CheckoutPageSection, { hasBorder: false, title: t('Billing and shipping information'), children: jsx(CheckoutPageSectionContent, { children: jsx(BillingAndInvoiceInformation, { billToAddress: cart.billTo && {
|
|
60
|
+
address1: cart.billTo.address1,
|
|
61
|
+
address2: cart.billTo.address2,
|
|
62
|
+
address3: cart.billTo.address3,
|
|
63
|
+
attention: '',
|
|
64
|
+
city: cart.billTo.city,
|
|
65
|
+
companyName: cart.billTo.companyName,
|
|
66
|
+
country: cart.billTo.country,
|
|
67
|
+
email: cart.billTo.email,
|
|
68
|
+
firstName: '',
|
|
69
|
+
lastName: '',
|
|
70
|
+
phone: cart.billTo.phone,
|
|
71
|
+
postalCode: cart.billTo.postalCode,
|
|
72
|
+
}, shipToAddress: cart.shipTo && {
|
|
73
|
+
address1: cart.shipTo.address1,
|
|
74
|
+
address2: cart.shipTo.address2,
|
|
75
|
+
address3: cart.shipTo.address3,
|
|
76
|
+
attention: '',
|
|
77
|
+
city: cart.shipTo.city,
|
|
78
|
+
companyName: cart.shipTo.companyName,
|
|
79
|
+
country: cart.shipTo.country,
|
|
80
|
+
email: cart.shipTo.email,
|
|
81
|
+
firstName: '',
|
|
82
|
+
lastName: '',
|
|
83
|
+
phone: cart.shipTo.phone,
|
|
84
|
+
postalCode: cart.shipTo.postalCode,
|
|
79
85
|
} }) }) }), jsx(CheckoutPageSection, { hasBorder: false, title: t('Order'), children: jsx(CheckoutPageSectionContent, { stretch: true, children: jsx(OrderLineList, { children: cart.cartLines?.map(cartLine => (jsx(OrderLineCard, { deliveryDate: undefined, href: cartLine.productUri, image: {
|
|
80
86
|
fit: 'contain',
|
|
81
87
|
image: {
|
|
@@ -6,9 +6,9 @@ import { useAlgoliaInsights } from '../../../../algolia/use-algolia-insights.js'
|
|
|
6
6
|
import { Accordion } from '../../../../collapsables/accordion/accordion.js';
|
|
7
7
|
import { AccordionItem } from '../../../../collapsables/accordion/accordion-item.js';
|
|
8
8
|
import { InfoDisplay } from '../../../../display/info-display/info-display.js';
|
|
9
|
-
import { Checkbox } from '../../../../forms/checkbox/checkbox.js';
|
|
10
|
-
import { Select } from '../../../../forms/select/select.js';
|
|
11
|
-
import { TextField } from '../../../../forms/text-field/text-field.js';
|
|
9
|
+
import { Checkbox } from '../../../../forms/elements/checkbox/checkbox.js';
|
|
10
|
+
import { Select } from '../../../../forms/elements/select/select.js';
|
|
11
|
+
import { TextField } from '../../../../forms/fields/text-field/text-field.js';
|
|
12
12
|
import { InfoIconTooltip } from '../../../../info-icon-tooltip/info-icon-tooltip.js';
|
|
13
13
|
import { FormattedMessage } from '../../../../intl/formatted-message.js';
|
|
14
14
|
import { isCountryCode } from '../../../../intl/types.js';
|
|
@@ -321,26 +321,32 @@ function Payment({ atp, cart: _cart, form, isProcessing, onError: _onError, onPa
|
|
|
321
321
|
/* eslint-disable ssr-friendly/no-dom-globals-in-react-fc */
|
|
322
322
|
typeof window === 'undefined'
|
|
323
323
|
? ''
|
|
324
|
-
: `${window.location.pathname}${window.location.search}` })), Boolean(paymentError) && (jsx("div", { className: styles['error-message'], children: jsx(FormattedMessage, { id: "An error occurred while processing your payment. Please try again." }) })), jsx(InfoDisplay, { id: "shipping-and-invoice-information", label: t('Billing and shipping address'), value: jsx(Accordion, { variant: "select", children: jsx(AccordionItem, { "data-test-selector": "billingAndShippingInformation", id: "invoice-and-shipping", isDisabled: isDisabled, title: t('Billing and shipping information'), children: jsx(BillingAndInvoiceInformation, { billToAddress: {
|
|
325
|
-
address1: cart.billTo
|
|
326
|
-
address2: cart.billTo
|
|
327
|
-
address3: cart.billTo
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
324
|
+
: `${window.location.pathname}${window.location.search}` })), Boolean(paymentError) && (jsx("div", { className: styles['error-message'], children: jsx(FormattedMessage, { id: "An error occurred while processing your payment. Please try again." }) })), jsx(InfoDisplay, { id: "shipping-and-invoice-information", label: t('Billing and shipping address'), value: jsx(Accordion, { variant: "select", children: jsx(AccordionItem, { "data-test-selector": "billingAndShippingInformation", id: "invoice-and-shipping", isDisabled: isDisabled, title: t('Billing and shipping information'), children: jsx(BillingAndInvoiceInformation, { billToAddress: cart.billTo && {
|
|
325
|
+
address1: cart.billTo.address1,
|
|
326
|
+
address2: cart.billTo.address2,
|
|
327
|
+
address3: cart.billTo.address3,
|
|
328
|
+
attention: '',
|
|
329
|
+
city: cart.billTo.city,
|
|
330
|
+
companyName: cart.billTo.companyName,
|
|
331
|
+
country: cart.billTo.country,
|
|
332
|
+
email: cart.billTo.email,
|
|
333
|
+
firstName: '',
|
|
334
|
+
lastName: '',
|
|
335
|
+
phone: cart.billTo.phone,
|
|
336
|
+
postalCode: cart.billTo.postalCode,
|
|
337
|
+
}, shipToAddress: cart.shipTo && {
|
|
338
|
+
address1: cart.shipTo.address1,
|
|
339
|
+
address2: cart.shipTo.address2,
|
|
340
|
+
address3: cart.shipTo.address3,
|
|
341
|
+
attention: '',
|
|
342
|
+
city: cart.shipTo.city,
|
|
343
|
+
companyName: cart.shipTo.companyName,
|
|
344
|
+
country: cart.shipTo.country,
|
|
345
|
+
email: cart.shipTo.email,
|
|
346
|
+
firstName: '',
|
|
347
|
+
lastName: '',
|
|
348
|
+
phone: cart.shipTo.phone,
|
|
349
|
+
postalCode: cart.shipTo.postalCode,
|
|
344
350
|
} }) }) }) })] }));
|
|
345
351
|
}
|
|
346
352
|
|
|
@@ -1,28 +1,14 @@
|
|
|
1
1
|
import { BillToModel } from '../../../../shared/api/storefront/model/storefront.model';
|
|
2
|
+
import { ValidAddress } from '../../../../shared/model/address';
|
|
2
3
|
import { Country } from '../../../../shared/model/countries-languages';
|
|
3
4
|
export declare const EDIT_ADDRESS_FORM_ID = "billToForm";
|
|
4
|
-
export interface Address {
|
|
5
|
-
address1: string;
|
|
6
|
-
address2: string;
|
|
7
|
-
address3: string;
|
|
8
|
-
attention: string;
|
|
9
|
-
city: string;
|
|
10
|
-
companyName: string;
|
|
11
|
-
country: Country;
|
|
12
|
-
email: string;
|
|
13
|
-
firstName: string;
|
|
14
|
-
lastName: string;
|
|
15
|
-
phone: string;
|
|
16
|
-
postalCode: string;
|
|
17
|
-
}
|
|
18
5
|
export interface EditAddressesFormData {
|
|
19
|
-
address:
|
|
6
|
+
address: ValidAddress;
|
|
20
7
|
notes: string | undefined;
|
|
21
8
|
}
|
|
22
|
-
export declare function
|
|
9
|
+
export declare function EditCheckoutBillToAddressForm({ billTo, countries, isLoading, isPickup, onSubmit, }: {
|
|
23
10
|
billTo: BillToModel | undefined | null;
|
|
24
11
|
countries: Country[];
|
|
25
|
-
currentCountry: Country | undefined;
|
|
26
12
|
isLoading: boolean;
|
|
27
13
|
isPickup: boolean;
|
|
28
14
|
onSubmit: (event: EditAddressesFormData) => void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Form } from 'react-aria-components';
|
|
4
|
+
import { Checkbox } from '../../../../forms/elements/checkbox/checkbox.js';
|
|
5
|
+
import { TextField } from '../../../../forms/fields/text-field/text-field.js';
|
|
6
|
+
import { EditAddressForm } from '../../../../forms/partials/edit-address-form/edit-address-form.js';
|
|
7
|
+
import { InfoIconTooltip } from '../../../../info-icon-tooltip/info-icon-tooltip.js';
|
|
8
|
+
import { FormattedMessage } from '../../../../intl/formatted-message.js';
|
|
9
|
+
import { useFormattedMessage } from '../../../../intl/use-formatted-message.js';
|
|
10
|
+
import { useFetchCurrentCart } from '../../../../shared/api/storefront/hooks/cart/use-fetch-current-cart.js';
|
|
11
|
+
import { CheckoutPageSection } from '../../layouts/checkout-page-layout/components/checkout-page-section.js';
|
|
12
|
+
import { CheckoutPageSectionContent } from '../../layouts/checkout-page-layout/components/checkout-page-section-content.js';
|
|
13
|
+
import { SonicAddress } from './sonic-address.js';
|
|
14
|
+
import styles from './edit-checkout-bill-to-address-form.module.css.js';
|
|
15
|
+
|
|
16
|
+
const EDIT_ADDRESS_FORM_ID = 'billToForm';
|
|
17
|
+
function EditCheckoutBillToAddressForm({ billTo, countries, isLoading, isPickup, onSubmit, }) {
|
|
18
|
+
const t = useFormattedMessage();
|
|
19
|
+
const { data: cart } = useFetchCurrentCart();
|
|
20
|
+
return (jsxs(Fragment, { children: [jsx(CheckoutPageSection, { title: jsx(FormattedMessage, { id: "Billing address" }), children: jsx(CheckoutPageSectionContent, { children: jsxs(Form, { className: styles.form, "data-test-selector": "billToAddressForm", id: EDIT_ADDRESS_FORM_ID, onSubmit: e => {
|
|
21
|
+
e.preventDefault();
|
|
22
|
+
const formData = new FormData(e.currentTarget);
|
|
23
|
+
const countryFormValue = formData.get('countrySelect')?.toString();
|
|
24
|
+
const country = countries.find(country => country.id === countryFormValue);
|
|
25
|
+
if (!country)
|
|
26
|
+
throw new Error(`Country not found ${formData.get('country')}`);
|
|
27
|
+
onSubmit({
|
|
28
|
+
address: {
|
|
29
|
+
address1: formData.get('address1')?.toString() || '',
|
|
30
|
+
address2: formData.get('address2')?.toString() || '',
|
|
31
|
+
address3: formData.get('address3')?.toString() || '',
|
|
32
|
+
attention: formData.get('attention')?.toString() || '',
|
|
33
|
+
city: formData.get('city')?.toString() || '',
|
|
34
|
+
companyName: formData.get('companyName')?.toString() || '',
|
|
35
|
+
country,
|
|
36
|
+
email: formData.get('email')?.toString() || '',
|
|
37
|
+
firstName: formData.get('firstName')?.toString() || '',
|
|
38
|
+
lastName: formData.get('lastName')?.toString() || '',
|
|
39
|
+
phone: formData.get('phone')?.toString() || '',
|
|
40
|
+
postalCode: formData.get('postalCode')?.toString() || '',
|
|
41
|
+
},
|
|
42
|
+
notes: cart?.notes === formData.get('notes')
|
|
43
|
+
? undefined
|
|
44
|
+
: formData.get('notes')?.toString() || '',
|
|
45
|
+
});
|
|
46
|
+
}, children: [jsx(EditAddressForm, { address: billTo, countries: countries, isLoading: isLoading }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { defaultValue: cart?.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, { children: jsx(Fragment, { children: isPickup ? (jsx(SonicAddress, {})) : (jsxs("div", { className: styles['use-invoice-checkbox'], children: [jsx(Checkbox, { "data-test-selector": "checkboxUseBillingAddress", isDisabled: true, isSelected: true, children: jsx(FormattedMessage, { id: "Use billing address" }) }), jsx(InfoIconTooltip, { variant: "stroke", children: t('Changing your address is currently not possible. Please contact customer support to change your address.') })] })) }) }) })] }));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { EDIT_ADDRESS_FORM_ID, EditCheckoutBillToAddressForm };
|
|
@@ -3,15 +3,15 @@ import { jsxs, jsx, Fragment } 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 { Link } from '../../../../buttons/link/link.js';
|
|
6
|
-
import { Checkbox } from '../../../../forms/checkbox/checkbox.js';
|
|
7
|
-
import { TextField } from '../../../../forms/text-field/text-field.js';
|
|
6
|
+
import { Checkbox } from '../../../../forms/elements/checkbox/checkbox.js';
|
|
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
10
|
import { PATHS } from '../../../paths.js';
|
|
11
11
|
import { CheckoutPageSection } from '../../layouts/checkout-page-layout/components/checkout-page-section.js';
|
|
12
12
|
import { CheckoutPageSectionContent } from '../../layouts/checkout-page-layout/components/checkout-page-section-content.js';
|
|
13
13
|
import { CheckoutPageSectionLink } from '../../layouts/checkout-page-layout/components/checkout-page-section-link.js';
|
|
14
|
-
import { EDIT_ADDRESS_FORM_ID } from './edit-address-form.js';
|
|
14
|
+
import { EDIT_ADDRESS_FORM_ID } from './edit-checkout-bill-to-address-form.js';
|
|
15
15
|
import { SonicAddress } from './sonic-address.js';
|
|
16
16
|
import styles from './readonly-address.module.css.js';
|
|
17
17
|
|
|
@@ -29,9 +29,10 @@ function ReadOnlyAddresses({ billTo, isLoading, isPickup, notes, onSubmit, shipT
|
|
|
29
29
|
address1: billTo.address1,
|
|
30
30
|
address2: billTo.address2,
|
|
31
31
|
address3: billTo.address3,
|
|
32
|
+
attention: billTo.attention,
|
|
32
33
|
city: billTo.city,
|
|
33
34
|
companyName: billTo.companyName,
|
|
34
|
-
country: billTo.country
|
|
35
|
+
country: billTo.country,
|
|
35
36
|
email: billTo.email,
|
|
36
37
|
firstName: billTo.firstName,
|
|
37
38
|
lastName: billTo.lastName,
|
|
@@ -41,9 +42,10 @@ function ReadOnlyAddresses({ billTo, isLoading, isPickup, notes, onSubmit, shipT
|
|
|
41
42
|
address1: shipTo.address1,
|
|
42
43
|
address2: shipTo.address2,
|
|
43
44
|
address3: shipTo.address3,
|
|
45
|
+
attention: shipTo.attention,
|
|
44
46
|
city: shipTo.city,
|
|
45
47
|
companyName: shipTo.companyName,
|
|
46
|
-
country: shipTo.country
|
|
48
|
+
country: shipTo.country,
|
|
47
49
|
email: shipTo.email,
|
|
48
50
|
firstName: shipTo.firstName,
|
|
49
51
|
lastName: shipTo.lastName,
|
|
@@ -3,7 +3,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
3
3
|
import { Button } from '../../../buttons/button/button.js';
|
|
4
4
|
import { CartTotals } from '../../../cart-totals/cart-totals.js';
|
|
5
5
|
import { CartTotalsSummary } from '../../../cart-totals/cart-totals-summary.js';
|
|
6
|
-
import { Select } from '../../../forms/select/select.js';
|
|
6
|
+
import { Select } from '../../../forms/elements/select/select.js';
|
|
7
7
|
import { FormattedMessage } from '../../../intl/formatted-message.js';
|
|
8
8
|
import { useFormattedMessage } from '../../../intl/use-formatted-message.js';
|
|
9
9
|
import { getCurrencyCodeBySymbol } from '../../../shared/model/currency.js';
|
|
@@ -12,7 +12,7 @@ import { PATHS } from '../../paths.js';
|
|
|
12
12
|
import { CheckoutPageLayout } from '../layouts/checkout-page-layout/checkout-page-layout.js';
|
|
13
13
|
import { CheckoutPageSection } from '../layouts/checkout-page-layout/components/checkout-page-section.js';
|
|
14
14
|
import { CheckoutPageSectionContent } from '../layouts/checkout-page-layout/components/checkout-page-section-content.js';
|
|
15
|
-
import { EDIT_ADDRESS_FORM_ID } from './components/edit-address-form.js';
|
|
15
|
+
import { EDIT_ADDRESS_FORM_ID } from './components/edit-checkout-bill-to-address-form.js';
|
|
16
16
|
import styles from './shipping-page.module.css.js';
|
|
17
17
|
|
|
18
18
|
function ShippingPageContent({ cart, editAddress, errorPatchBillingAddress, fulfillmentMethods, isGuest, isLoadingFulfillmentMethods, isPatching, isPatchingSession, onChangeFulfillmentMethod, readOnlyAddress, }) {
|
|
@@ -14,7 +14,7 @@ import { ErrorPage } from '../../error-page/error-page.js';
|
|
|
14
14
|
import { LoadingPage } from '../../loading-page/loading-page.js';
|
|
15
15
|
import { PATHS } from '../../paths.js';
|
|
16
16
|
import { CurrencyChangeDialog } from './components/currency-change-dialog.js';
|
|
17
|
-
import {
|
|
17
|
+
import { EditCheckoutBillToAddressForm } from './components/edit-checkout-bill-to-address-form.js';
|
|
18
18
|
import { ReadOnlyAddresses } from './components/readonly-address.js';
|
|
19
19
|
import { usePatchShippingDetails } from './hooks/use-patch-shipping-details.js';
|
|
20
20
|
import { ShippingPageContent } from './shipping-page-content.js';
|
|
@@ -123,7 +123,7 @@ function ShippingPage() {
|
|
|
123
123
|
return (jsx(ShippingPageContent, { cart: cart,
|
|
124
124
|
// TODO: Combine editAddress and readOnlyAddress into one section in order
|
|
125
125
|
// for typescript to correctly infer which properties are set in what case
|
|
126
|
-
editAddress: jsxs(Fragment, { children: [jsx(
|
|
126
|
+
editAddress: jsxs(Fragment, { children: [jsx(EditCheckoutBillToAddressForm, { billTo: cart.billTo, countries: countries || [], isLoading: isPatching, isPickup: isPickup, onSubmit: async ({ address, notes }) => {
|
|
127
127
|
if (!cart.billTo)
|
|
128
128
|
return;
|
|
129
129
|
formData.current = { address, notes };
|
|
@@ -4,7 +4,7 @@ import resetStyles from '../../../shared/reset.module.css.js';
|
|
|
4
4
|
import styles from './page-container.module.css.js';
|
|
5
5
|
|
|
6
6
|
function PageContainer({ breadcrumbSlot, children, className, 'data-test-selector': dataTestSelector, fluid, fullHeight, titleSlot, }) {
|
|
7
|
-
return (jsx("div", { className: clsx(styles['page-container'], resetStyles.reset, fullHeight && styles['full-height'], fluid && styles['fluid'], className), "data-test-selector": dataTestSelector, children: jsxs("
|
|
7
|
+
return (jsx("div", { className: clsx(styles['page-container'], resetStyles.reset, fullHeight && styles['full-height'], fluid && styles['fluid'], className), "data-test-selector": dataTestSelector, children: jsxs("div", { className: styles['page-main'], children: [breadcrumbSlot && (jsx("div", { className: styles.breadcrumb, children: breadcrumbSlot })), titleSlot && jsx("div", { className: styles.title, children: titleSlot }), jsx("div", { className: styles.content, children: children })] }) }));
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export { PageContainer };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BillToCollectionModel } from '../../../../shared/api/storefront/model/storefront.model';
|
|
2
2
|
export interface ChangeCustomerDialogProps {
|
|
3
|
-
|
|
3
|
+
allowSetDefault?: boolean;
|
|
4
4
|
data?: BillToCollectionModel;
|
|
5
|
+
defaultCustomerId?: string;
|
|
5
6
|
error?: Error | null | unknown;
|
|
6
7
|
filter?: string;
|
|
7
8
|
hasErrorSubmitting?: boolean;
|
|
@@ -9,7 +10,7 @@ export interface ChangeCustomerDialogProps {
|
|
|
9
10
|
isOpen: boolean;
|
|
10
11
|
isUpdating?: boolean;
|
|
11
12
|
onClose: () => void;
|
|
12
|
-
onCustomerSelected: (id: string) => void;
|
|
13
|
+
onCustomerSelected: (id: string, setAsDefault: boolean) => void;
|
|
13
14
|
onFilterChanged?: (filter: string) => void;
|
|
14
15
|
}
|
|
15
|
-
export declare function ChangeCustomerDialog({
|
|
16
|
+
export declare function ChangeCustomerDialog({ allowSetDefault, data, defaultCustomerId, error, filter, hasErrorSubmitting, isLoading, isOpen, isUpdating, onClose, onCustomerSelected, onFilterChanged, }: ChangeCustomerDialogProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -8,17 +8,23 @@ import { Dialog } from '../../../../modals/dialog/dialog.js';
|
|
|
8
8
|
import { ChangeCustomer } from './change-customer.js';
|
|
9
9
|
import styles from './change-customer-dialog.module.css.js';
|
|
10
10
|
|
|
11
|
-
function ChangeCustomerDialog({
|
|
11
|
+
function ChangeCustomerDialog({ allowSetDefault = false, data, defaultCustomerId, error, filter, hasErrorSubmitting, isLoading, isOpen, isUpdating = false, onClose, onCustomerSelected, onFilterChanged, }) {
|
|
12
12
|
const t = useFormattedMessage();
|
|
13
13
|
const [hasCustomerSelected, setHasCustomerSelected] = useState(false);
|
|
14
14
|
const [selectedCustomerId, setSelectedCustomerId] = useState();
|
|
15
|
-
|
|
15
|
+
const [setAsDefault, setSetAsDefault] = useState(false);
|
|
16
|
+
if (!isOpen && setAsDefault)
|
|
17
|
+
setSetAsDefault(false);
|
|
18
|
+
if (!isOpen)
|
|
19
|
+
return null;
|
|
20
|
+
return (jsx(Dialog, { allowSubmit: !hasErrorSubmitting && hasCustomerSelected, className: styles['change-customer-dialog'], isOpen: isOpen, isSubmitting: isUpdating || hasErrorSubmitting, onOpenChange: isOpen => !isOpen && onClose(), onSubmit: () => selectedCustomerId &&
|
|
21
|
+
onCustomerSelected(selectedCustomerId, setAsDefault), title: t('Change customer'), children: hasErrorSubmitting ? (jsx(Message, { className: styles.error, type: "danger", children: jsx(FormattedMessage, { id: "An error occurred while changing the customer." }) })) : (jsx(ChangeCustomer, { allowSetDefault: allowSetDefault, className: styles.content, data: data, defaultCustomerId: defaultCustomerId, error: error, filter: filter, isLoading: isLoading, onCustomerSelected: id => {
|
|
16
22
|
setSelectedCustomerId(id);
|
|
17
|
-
onCustomerSelected(id);
|
|
23
|
+
onCustomerSelected(id, setAsDefault);
|
|
18
24
|
}, onCustomerSelectionChanged: id => {
|
|
19
25
|
setSelectedCustomerId(id);
|
|
20
26
|
setHasCustomerSelected(true);
|
|
21
|
-
}, onFilterChanged: onFilterChanged,
|
|
27
|
+
}, onFilterChanged: onFilterChanged, onSetAsDefaultChange: setSetAsDefault, setAsDefault: setAsDefault })) }));
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
export { ChangeCustomerDialog };
|