@sonic-equipment/ui 137.0.0 → 138.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/algolia/algolia-categories-filters.js +1 -1
- package/dist/algolia/algolia-query-string-routing.js +4 -2
- package/dist/buttons/add-to-cart-button/add-to-cart-button.js +1 -1
- package/dist/buttons/link/link.d.ts +1 -2
- package/dist/buttons/link/link.js +4 -6
- package/dist/collapsables/accordion/accordion-item.js +1 -1
- package/dist/collapsables/accordion/accordion.module.css.js +1 -1
- package/dist/exports.d.ts +4 -1
- package/dist/footer/footer.js +1 -1
- package/dist/forms/textarea/textarea.js +1 -1
- package/dist/index.js +4 -1
- package/dist/intl/translation-id.d.ts +1 -1
- package/dist/lists/orderline-list/orderline-list.js +1 -1
- package/dist/media/image/image.js +3 -3
- package/dist/message/message.d.ts +6 -0
- package/dist/message/message.js +19 -0
- package/dist/message/message.module.css.js +3 -0
- package/dist/pages/account/layouts/sign-in-page-layout/sign-in-page-layout.d.ts +8 -0
- package/dist/pages/account/layouts/sign-in-page-layout/sign-in-page-layout.js +12 -0
- package/dist/pages/account/layouts/sign-in-page-layout/sign-in-page-layout.module.css.js +3 -0
- package/dist/pages/account/sign-in-page/sign-in-page.d.ts +3 -0
- package/dist/pages/account/sign-in-page/sign-in-page.js +56 -0
- package/dist/pages/checkout/cart-page/cart-page.js +6 -6
- package/dist/pages/checkout/order-confirmation-page/order-confirmation-page-content.js +4 -4
- package/dist/pages/checkout/order-confirmation-page/order-confirmation-page.js +3 -3
- package/dist/pages/checkout/payment-page/components/adyen-payment.d.ts +2 -1
- package/dist/pages/checkout/payment-page/components/adyen-payment.js +2 -2
- package/dist/pages/checkout/payment-page/components/payment.d.ts +7 -3
- package/dist/pages/checkout/payment-page/components/payment.js +42 -41
- package/dist/pages/checkout/payment-page/payment-page-content.d.ts +3 -3
- package/dist/pages/checkout/payment-page/payment-page-content.js +7 -7
- package/dist/pages/checkout/payment-page/payment-page.js +7 -7
- package/dist/pages/checkout/shipping-page/components/readonly-address.js +3 -3
- package/dist/pages/checkout/shipping-page/shipping-page-content.js +4 -4
- package/dist/pages/checkout/shipping-page/shipping-page.js +5 -5
- package/dist/pages/components/page/page.d.ts +4 -2
- package/dist/pages/components/page/page.js +4 -6
- package/dist/pages/components/page-container/page-container.d.ts +5 -1
- package/dist/pages/components/page-container/page-container.js +3 -3
- package/dist/pages/components/page-container/page-container.module.css.js +1 -1
- package/dist/pages/error-page/error-page.js +4 -3
- package/dist/pages/{checkout/constants.d.ts → paths.d.ts} +4 -1
- package/dist/pages/{checkout/constants.js → paths.js} +5 -2
- package/dist/pages/product/product-details-page/product-details.js +1 -1
- package/dist/pages/product/product-listing-page/no-results/no-results.js +1 -1
- package/dist/pages/product/product-listing-page/product-listing.js +1 -1
- package/dist/pages/product/search-result-page/search-results-page.js +3 -1
- package/dist/shared/api/storefront/hooks/authentication/use-create-guest-account.d.ts +1 -3
- package/dist/shared/api/storefront/hooks/authentication/use-create-guest-account.js +26 -11
- package/dist/shared/api/storefront/hooks/authentication/use-fetch-session.js +1 -0
- package/dist/shared/api/storefront/hooks/authentication/use-sign-in.d.ts +1 -0
- package/dist/shared/api/storefront/hooks/authentication/use-sign-in.js +4 -4
- package/dist/shared/api/storefront/services/authentication-service.d.ts +6 -7
- package/dist/shared/api/storefront/services/authentication-service.js +5 -3
- package/dist/shared/api/storefront/services/translation-service.js +2 -1
- package/dist/shared/model/currency.d.ts +1 -28
- package/dist/shared/model/image.d.ts +3 -3
- package/dist/shared/routing/with-routing.js +1 -1
- package/dist/shared/utils/local-storage.d.ts +1 -1
- package/dist/shared/utils/local-storage.js +4 -5
- package/dist/shared/utils/price.d.ts +3 -37
- package/dist/sign-in-form/sign-in-form.d.ts +12 -6
- package/dist/sign-in-form/sign-in-form.js +9 -6
- package/dist/styles.css +399 -158
- package/package.json +1 -1
- package/dist/pages/components/page/page.module.css.js +0 -3
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
import { useQueryClient, useMutation } from '@tanstack/react-query';
|
|
2
|
-
import { createGuestAccount, createSession } from '../../services/authentication-service.js';
|
|
2
|
+
import { fetchSession, createGuestAccount, createSession } from '../../services/authentication-service.js';
|
|
3
3
|
|
|
4
4
|
function useCreateGuestAccount() {
|
|
5
5
|
const queryClient = useQueryClient();
|
|
6
6
|
return useMutation({
|
|
7
|
-
mutationFn: async (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
mutationFn: async () => {
|
|
8
|
+
try {
|
|
9
|
+
let session = queryClient.getQueryData(['session']);
|
|
10
|
+
if (!session) {
|
|
11
|
+
session = await fetchSession();
|
|
12
|
+
queryClient.setQueryData(['session'], session);
|
|
13
|
+
}
|
|
14
|
+
if (!session.pickUpWarehouse) {
|
|
15
|
+
throw new Error('No default pick up warehouse found');
|
|
16
|
+
}
|
|
17
|
+
const defaultWarehouseId = session.pickUpWarehouse.id;
|
|
18
|
+
const body = await createGuestAccount({ defaultWarehouseId });
|
|
19
|
+
await createSession({
|
|
20
|
+
accessToken: body.accessToken,
|
|
21
|
+
isGuest: true,
|
|
22
|
+
password: body.password,
|
|
23
|
+
rememberMe: false,
|
|
24
|
+
userName: body.userName,
|
|
25
|
+
});
|
|
26
|
+
return body;
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
queryClient.resetQueries();
|
|
30
|
+
queryClient.clear();
|
|
31
|
+
}
|
|
17
32
|
},
|
|
18
33
|
});
|
|
19
34
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AuthenticationResponse } from '../../services/authentication-service';
|
|
2
2
|
export declare function useSignIn(): import("@tanstack/react-query").UseMutationResult<AuthenticationResponse, Error, {
|
|
3
3
|
password: string;
|
|
4
|
+
rememberMe: boolean;
|
|
4
5
|
userName: string;
|
|
5
6
|
}, unknown>;
|
|
@@ -4,20 +4,20 @@ import { signIn, createSession } from '../../services/authentication-service.js'
|
|
|
4
4
|
function useSignIn() {
|
|
5
5
|
const queryClient = useQueryClient();
|
|
6
6
|
return useMutation({
|
|
7
|
-
mutationFn: async ({ password, userName }) => {
|
|
7
|
+
mutationFn: async ({ password, rememberMe, userName }) => {
|
|
8
8
|
try {
|
|
9
9
|
const body = await signIn({ password, userName });
|
|
10
10
|
await createSession({
|
|
11
11
|
accessToken: body.access_token,
|
|
12
|
+
isGuest: false,
|
|
12
13
|
password,
|
|
14
|
+
rememberMe,
|
|
13
15
|
userName,
|
|
14
16
|
});
|
|
15
|
-
queryClient.resetQueries();
|
|
16
17
|
return body;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
+
finally {
|
|
19
20
|
queryClient.resetQueries();
|
|
20
|
-
throw error;
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
});
|
|
@@ -14,17 +14,16 @@ export declare function signIn({ password, userName, }: {
|
|
|
14
14
|
userName: string;
|
|
15
15
|
}): Promise<AuthenticationResponse>;
|
|
16
16
|
export interface CreateSessionRequestBody {
|
|
17
|
-
isGuest
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
isGuest: boolean;
|
|
18
|
+
keepMeSignedIn?: boolean;
|
|
19
|
+
password: string | undefined;
|
|
20
|
+
rememberMe: boolean | undefined;
|
|
20
21
|
returnUrl?: string | undefined;
|
|
21
22
|
userName: string;
|
|
22
23
|
}
|
|
23
|
-
export declare function createSession({ accessToken, password, userName, }: {
|
|
24
|
+
export declare function createSession({ accessToken, isGuest, keepMeSignedIn, password, rememberMe, returnUrl, userName, }: {
|
|
24
25
|
accessToken: string;
|
|
25
|
-
|
|
26
|
-
userName: string;
|
|
27
|
-
}): Promise<SessionModel>;
|
|
26
|
+
} & CreateSessionRequestBody): Promise<SessionModel>;
|
|
28
27
|
export declare function signOut(): Promise<void>;
|
|
29
28
|
export declare function createGuestAccount({ defaultWarehouseId, }: {
|
|
30
29
|
defaultWarehouseId: string;
|
|
@@ -37,12 +37,14 @@ async function signIn({ password, userName, }) {
|
|
|
37
37
|
});
|
|
38
38
|
return body;
|
|
39
39
|
}
|
|
40
|
-
async function createSession({ accessToken, password, userName, }) {
|
|
40
|
+
async function createSession({ accessToken, isGuest, keepMeSignedIn, password, rememberMe, returnUrl, userName, }) {
|
|
41
41
|
const { body } = await request({
|
|
42
42
|
body: {
|
|
43
|
-
isGuest
|
|
43
|
+
isGuest,
|
|
44
|
+
keepMeSignedIn,
|
|
44
45
|
password,
|
|
45
|
-
rememberMe
|
|
46
|
+
rememberMe,
|
|
47
|
+
returnUrl,
|
|
46
48
|
userName,
|
|
47
49
|
},
|
|
48
50
|
headers: {
|
|
@@ -8,7 +8,8 @@ async function fetchTranslations(languageCode) {
|
|
|
8
8
|
url: `${config.SHOP_API_URL}/api/v1/translationdictionaries?page=1&pageSize=9999&languageCode=${languageCode}`,
|
|
9
9
|
});
|
|
10
10
|
body.translationDictionaries?.forEach(dictionary => {
|
|
11
|
-
translations[dictionary.keyword.toLowerCase()] =
|
|
11
|
+
translations[dictionary.keyword.toLowerCase()] =
|
|
12
|
+
dictionary.translation;
|
|
12
13
|
});
|
|
13
14
|
return translations;
|
|
14
15
|
}
|
|
@@ -1,28 +1 @@
|
|
|
1
|
-
export declare const currencySymbolToISO:
|
|
2
|
-
readonly '': "EUR";
|
|
3
|
-
readonly $: "USD";
|
|
4
|
-
readonly 'Bs.': "VES";
|
|
5
|
-
readonly Ft: "HUF";
|
|
6
|
-
readonly Kč: "CZK";
|
|
7
|
-
readonly R: "ZAR";
|
|
8
|
-
readonly kr: "SEK";
|
|
9
|
-
readonly lei: "RON";
|
|
10
|
-
readonly zł: "PLN";
|
|
11
|
-
readonly '\u00A3': "GBP";
|
|
12
|
-
readonly '\u00A5': "JPY";
|
|
13
|
-
readonly '\u0E3F': "THB";
|
|
14
|
-
readonly '\u20A1': "CRC";
|
|
15
|
-
readonly '\u20A6': "NGN";
|
|
16
|
-
readonly '\u20A9': "KRW";
|
|
17
|
-
readonly '\u20AA': "ILS";
|
|
18
|
-
readonly '\u20AB': "VND";
|
|
19
|
-
readonly '\u20AC': "EUR";
|
|
20
|
-
readonly '\u20AE': "MNT";
|
|
21
|
-
readonly '\u20B1': "PHP";
|
|
22
|
-
readonly '\u20B2': "PYG";
|
|
23
|
-
readonly '\u20B4': "UAH";
|
|
24
|
-
readonly '\u20B5': "GHS";
|
|
25
|
-
readonly '\u20B9': "INR";
|
|
26
|
-
readonly '\u20BA': "TRY";
|
|
27
|
-
readonly '\u20BD': "RUB";
|
|
28
|
-
};
|
|
1
|
+
export declare const currencySymbolToISO: Record<string, string>;
|
|
@@ -19,8 +19,8 @@ export interface ImageSourceType {
|
|
|
19
19
|
}
|
|
20
20
|
export interface ResponsiveImageType {
|
|
21
21
|
altText: string;
|
|
22
|
-
lg
|
|
23
|
-
md
|
|
24
|
-
sm
|
|
22
|
+
lg?: DPRSrcSet;
|
|
23
|
+
md?: DPRSrcSet;
|
|
24
|
+
sm?: DPRSrcSet;
|
|
25
25
|
}
|
|
26
26
|
export declare function isResponsiveImage(image: ImageType | ResponsiveImageType | undefined): image is ResponsiveImageType;
|
|
@@ -57,14 +57,14 @@ function createStorage() {
|
|
|
57
57
|
});
|
|
58
58
|
Object.defineProperty(s, 'getItem', {
|
|
59
59
|
get: () => {
|
|
60
|
-
return k => {
|
|
60
|
+
return (k) => {
|
|
61
61
|
return s.hasOwnProperty(String(k)) ? s[String(k)] : null;
|
|
62
62
|
};
|
|
63
63
|
},
|
|
64
64
|
});
|
|
65
65
|
Object.defineProperty(s, 'removeItem', {
|
|
66
66
|
get: () => {
|
|
67
|
-
return k => {
|
|
67
|
+
return (k) => {
|
|
68
68
|
if (s.hasOwnProperty(String(k))) {
|
|
69
69
|
delete s[String(k)];
|
|
70
70
|
}
|
|
@@ -86,9 +86,8 @@ function createStorage() {
|
|
|
86
86
|
},
|
|
87
87
|
});
|
|
88
88
|
Object.defineProperty(s, 'key', {
|
|
89
|
-
value: k => {
|
|
90
|
-
|
|
91
|
-
return key ?? null;
|
|
89
|
+
value: (k) => {
|
|
90
|
+
return Object.keys(s)[k] || null;
|
|
92
91
|
},
|
|
93
92
|
});
|
|
94
93
|
Object.defineProperty(s, 'itemInsertionCallback', {
|
|
@@ -1,39 +1,5 @@
|
|
|
1
1
|
export declare const formatPrice: (price: number) => string;
|
|
2
|
-
export declare const currencies: {
|
|
3
|
-
|
|
4
|
-
AU: string;
|
|
5
|
-
BR: string;
|
|
6
|
-
CA: string;
|
|
7
|
-
CH: string;
|
|
8
|
-
CN: string;
|
|
9
|
-
CZ: string;
|
|
10
|
-
DK: string;
|
|
11
|
-
GB: string;
|
|
12
|
-
HK: string;
|
|
13
|
-
HR: string;
|
|
14
|
-
HU: string;
|
|
15
|
-
ID: string;
|
|
16
|
-
IN: string;
|
|
17
|
-
JP: string;
|
|
18
|
-
KR: string;
|
|
19
|
-
LA: string;
|
|
20
|
-
MG: string;
|
|
21
|
-
MX: string;
|
|
22
|
-
MY: string;
|
|
23
|
-
NO: string;
|
|
24
|
-
NZ: string;
|
|
25
|
-
PH: string;
|
|
26
|
-
PL: string;
|
|
27
|
-
RO: string;
|
|
28
|
-
RS: string;
|
|
29
|
-
RU: string;
|
|
30
|
-
SE: string;
|
|
31
|
-
SG: string;
|
|
32
|
-
SK: string;
|
|
33
|
-
TH: string;
|
|
34
|
-
TW: string;
|
|
35
|
-
US: string;
|
|
36
|
-
VN: string;
|
|
37
|
-
default: string;
|
|
2
|
+
export declare const currencies: Record<string, string> & {
|
|
3
|
+
default: 'EUR';
|
|
38
4
|
};
|
|
39
|
-
export declare const getCurrencyByCountryCode: (countryCode: string) =>
|
|
5
|
+
export declare const getCurrencyByCountryCode: (countryCode: string) => string;
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
interface LoginData {
|
|
2
2
|
email: string;
|
|
3
|
-
|
|
3
|
+
guestSignIn: false;
|
|
4
4
|
password: string;
|
|
5
|
-
|
|
5
|
+
rememberMe: boolean;
|
|
6
6
|
}
|
|
7
7
|
interface GuestLoginData {
|
|
8
|
-
|
|
8
|
+
guestSignIn: true;
|
|
9
9
|
}
|
|
10
|
+
export type SubmitData = LoginData | GuestLoginData;
|
|
11
|
+
export type ErrorMessage = 'Access denied' | 'Unexpected error';
|
|
10
12
|
export interface SignInFormProps {
|
|
11
13
|
allowGuestSignIn?: boolean;
|
|
14
|
+
errorMessage?: ErrorMessage;
|
|
12
15
|
initialEmail?: string;
|
|
13
|
-
|
|
16
|
+
initialRememberMe?: boolean;
|
|
17
|
+
isDisabled?: boolean;
|
|
18
|
+
isPendingGuestSignIn?: boolean;
|
|
19
|
+
isPendingUserSignIn?: boolean;
|
|
14
20
|
onSubmit?: ({ data }: {
|
|
15
|
-
data:
|
|
21
|
+
data: SubmitData;
|
|
16
22
|
}) => void;
|
|
17
23
|
}
|
|
18
|
-
export declare function SignInForm({ allowGuestSignIn, initialEmail,
|
|
24
|
+
export declare function SignInForm({ allowGuestSignIn, errorMessage, initialEmail, initialRememberMe, isDisabled: _isDisabled, isPendingGuestSignIn, isPendingUserSignIn, onSubmit, }: SignInFormProps): import("react/jsx-runtime").JSX.Element;
|
|
19
25
|
export {};
|
|
@@ -7,12 +7,15 @@ import { Link } from '../buttons/link/link.js';
|
|
|
7
7
|
import { Switch } from '../forms/switch/switch.js';
|
|
8
8
|
import { TextField } from '../forms/text-field/text-field.js';
|
|
9
9
|
import { useFormattedMessage } from '../intl/use-formatted-message.js';
|
|
10
|
+
import { Message } from '../message/message.js';
|
|
10
11
|
import { Heading } from '../typography/heading/heading.js';
|
|
11
12
|
import styles from './sign-in-form.module.css.js';
|
|
12
13
|
|
|
13
14
|
const GUEST_SIGN_IN_BUTTON_NAME = 'guestSignin';
|
|
14
|
-
function SignInForm({ allowGuestSignIn = false, initialEmail,
|
|
15
|
+
function SignInForm({ allowGuestSignIn = false, errorMessage, initialEmail, initialRememberMe, isDisabled: _isDisabled = false, isPendingGuestSignIn = false, isPendingUserSignIn = false, onSubmit = () => { }, }) {
|
|
15
16
|
const t = useFormattedMessage();
|
|
17
|
+
const title = t('sign in');
|
|
18
|
+
const isDisabled = isPendingUserSignIn || isPendingGuestSignIn || _isDisabled;
|
|
16
19
|
const handleSubmit = (event) => {
|
|
17
20
|
event.preventDefault();
|
|
18
21
|
const form = event.currentTarget;
|
|
@@ -22,14 +25,14 @@ function SignInForm({ allowGuestSignIn = false, initialEmail, initialRemember, o
|
|
|
22
25
|
if (submitter?.name === GUEST_SIGN_IN_BUTTON_NAME) {
|
|
23
26
|
return onSubmit({
|
|
24
27
|
data: {
|
|
25
|
-
|
|
28
|
+
guestSignIn: true,
|
|
26
29
|
},
|
|
27
30
|
});
|
|
28
31
|
}
|
|
29
32
|
// regular sign-in
|
|
30
33
|
const email = formData.get('email')?.toString();
|
|
31
34
|
const password = formData.get('password')?.toString();
|
|
32
|
-
const
|
|
35
|
+
const rememberMe = Boolean(formData.get('rememberMe'));
|
|
33
36
|
if (!email)
|
|
34
37
|
throw new Error('Email value is required');
|
|
35
38
|
if (!password)
|
|
@@ -37,13 +40,13 @@ function SignInForm({ allowGuestSignIn = false, initialEmail, initialRemember, o
|
|
|
37
40
|
onSubmit({
|
|
38
41
|
data: {
|
|
39
42
|
email,
|
|
40
|
-
|
|
43
|
+
guestSignIn: false,
|
|
41
44
|
password,
|
|
42
|
-
|
|
45
|
+
rememberMe,
|
|
43
46
|
},
|
|
44
47
|
});
|
|
45
48
|
};
|
|
46
|
-
return (jsxs(Form, { "aria-label":
|
|
49
|
+
return (jsxs(Form, { "aria-label": title, autoComplete: "off", className: clsx(styles['sign-in-form'], styles['form']), onSubmit: handleSubmit, validationBehavior: "native", children: [jsx("header", { className: styles['form-header'], children: jsx(Heading, { "data-test-selector": "PageTitle", italic: true, size: "m", tag: "h1", uppercase: true, children: title }) }), errorMessage === 'Access denied' && (jsx(Message, { type: "danger", children: t('Your email and password were not recognized.') })), errorMessage === 'Unexpected error' && (jsx(Message, { type: "danger", children: t('An unexpected error occured. Please try again.') })), jsxs("fieldset", { className: clsx(styles['form-fieldset'], styles['columns']), children: [jsx("div", { className: styles['form-segment'], children: jsx(TextField, { "data-test-selector": "signIn_userName", defaultValue: initialEmail, isDisabled: isDisabled, isRequired: true, label: t('Email'), name: "email", showLabel: true, type: "email" }) }), jsx("div", { className: styles['form-segment'], children: jsx(TextField, { "data-test-selector": "signIn_password", isDisabled: isDisabled, isRequired: true, label: t('Password'), name: "password", showLabel: true, type: "password" }) })] }), jsxs("footer", { className: styles['form-footer'], children: [jsx("div", { className: styles['form-segment'], children: jsx(Switch, { className: styles['floating'], defaultSelected: initialRememberMe, isDisabled: isDisabled, name: "rememberMe", value: "true", children: t('Remember me') }) }), jsx("div", { className: styles['form-segment'], children: jsx(Button, { "data-test-selector": "signIn_submit", isDisabled: isDisabled, isLoading: isPendingUserSignIn && t('Signing in…'), type: "submit", withArrow: true, children: t('sign in') }) }), jsxs("div", { className: styles['form-segment'], children: [jsx("p", { children: jsx(Link, { color: "primary", "data-test-selector": "signIn_forgotPassword", hasUnderline: true, href: "#", isDisabled: isDisabled, children: t('Forgot password?') }) }), jsxs("p", { children: [t('New user?'), ' ', jsx(Link, { "data-test-selector": "signInCreateNewAccount_createNewAccount", hasUnderline: true, href: "#", isDisabled: isDisabled, children: t('create account') })] })] }), allowGuestSignIn && (jsx("div", { className: styles['form-segment'], children: jsx(Button, { color: "secondary", isDisabled: isDisabled, isLoading: isPendingGuestSignIn && t('Signing in…'), isValidating: false, name: GUEST_SIGN_IN_BUTTON_NAME, type: "submit", value: "true", variant: "outline", children: t('Or continue as guest') }) }))] })] }));
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
export { SignInForm };
|