@sonic-equipment/ui 183.0.0 → 185.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/cards/data-card/data-card.js +37 -20
- package/dist/cards/data-card/data-card.module.css.js +1 -1
- package/dist/country-selector/country-selector-dialog/country-selector-dialog.js +1 -5
- package/dist/exports.d.ts +20 -2
- package/dist/forms/form/form.d.ts +7 -3
- package/dist/forms/form/form.js +2 -2
- package/dist/forms/password-validation/password-validation.d.ts +4 -0
- package/dist/forms/password-validation/password-validation.js +32 -0
- package/dist/forms/select/select.d.ts +2 -1
- package/dist/forms/select/select.js +2 -2
- package/dist/header/connected-header.js +1 -1
- package/dist/header/header.d.ts +1 -3
- package/dist/header/header.js +2 -2
- package/dist/index.js +21 -3
- package/dist/intl/translation-id.d.ts +1 -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/recover-password/recover-password-dialog.js +1 -3
- package/dist/pages/account/components/create-account-form/create-account-form.js +2 -17
- 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/layouts/checkout-page-layout/checkout-page-layout.js +2 -1
- package/dist/pages/checkout/shipping-page/hooks/use-patch-shipping-details.d.ts +1 -0
- 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 +16 -7
- 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-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 +2 -2
- 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/hooks/use-watch-css-property.js +9 -1
- package/dist/styles.css +354 -241
- package/package.json +1 -1
- /package/dist/shared/api/storefront/hooks/{authentication → account}/use-create-guest-account.d.ts +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { config } from '../../../../config.js';
|
|
2
|
+
import { request, RequestError, isRequestError } from '../../../fetch/request.js';
|
|
3
|
+
|
|
4
|
+
async function fetchCurrentAccount() {
|
|
5
|
+
const { body } = await request({
|
|
6
|
+
url: `${config.SHOP_API_URL}/api/v1/accounts/current`,
|
|
7
|
+
});
|
|
8
|
+
return body;
|
|
9
|
+
}
|
|
10
|
+
class ExistingAccountError extends RequestError {
|
|
11
|
+
constructor(error) {
|
|
12
|
+
super(error);
|
|
13
|
+
this.name = 'ExistingAccountError';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
async function createAccount({ companyName, countryCode, email, firstName, isPrivateAccount, isSubscribed, lastName, password, }) {
|
|
17
|
+
try {
|
|
18
|
+
const { body } = await request({
|
|
19
|
+
body: {
|
|
20
|
+
email,
|
|
21
|
+
firstName,
|
|
22
|
+
isSubscribed,
|
|
23
|
+
lastName,
|
|
24
|
+
password,
|
|
25
|
+
properties: {
|
|
26
|
+
PrivateAccount: isPrivateAccount,
|
|
27
|
+
companyName,
|
|
28
|
+
countryCode,
|
|
29
|
+
},
|
|
30
|
+
userName: '',
|
|
31
|
+
},
|
|
32
|
+
headers: {
|
|
33
|
+
'Content-Type': 'application/json',
|
|
34
|
+
},
|
|
35
|
+
method: 'POST',
|
|
36
|
+
url: `${config.SHOP_API_URL}/api/v1/accounts`,
|
|
37
|
+
});
|
|
38
|
+
return body;
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
if (isRequestError(error) &&
|
|
42
|
+
error.status === 400 &&
|
|
43
|
+
error.body?.message === 'Email Address already exists')
|
|
44
|
+
throw new ExistingAccountError(error);
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function createGuestAccount({ defaultWarehouseId, }) {
|
|
49
|
+
const { body } = await request({
|
|
50
|
+
body: {
|
|
51
|
+
defaultFulfillmentMethod: 'Ship',
|
|
52
|
+
defaultWarehouseId,
|
|
53
|
+
isGuest: true,
|
|
54
|
+
},
|
|
55
|
+
headers: {
|
|
56
|
+
'Content-Type': 'application/json',
|
|
57
|
+
},
|
|
58
|
+
method: 'POST',
|
|
59
|
+
url: `${config.SHOP_API_URL}/api/v1/accounts`,
|
|
60
|
+
});
|
|
61
|
+
return body;
|
|
62
|
+
}
|
|
63
|
+
async function patchCurrentAccount({ account, }) {
|
|
64
|
+
try {
|
|
65
|
+
const { body } = await request({
|
|
66
|
+
body: account,
|
|
67
|
+
headers: {
|
|
68
|
+
'Content-Type': 'application/json',
|
|
69
|
+
},
|
|
70
|
+
method: 'PATCH',
|
|
71
|
+
url: `${config.SHOP_API_URL}/api/v1/accounts/current`,
|
|
72
|
+
});
|
|
73
|
+
return body;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
if (isRequestError(error) &&
|
|
77
|
+
error.status === 400 &&
|
|
78
|
+
error.body?.message === 'Email Address already exists')
|
|
79
|
+
throw new ExistingAccountError(error);
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { ExistingAccountError, createAccount, createGuestAccount, fetchCurrentAccount, patchCurrentAccount };
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { RequestError } from '../../../fetch/request';
|
|
2
|
-
import {
|
|
2
|
+
import { PatchSessionModel, SessionModel } from '../model/storefront.model';
|
|
3
3
|
export declare function fetchSession(): Promise<SessionModel>;
|
|
4
|
+
export declare class InvalidPasswordError extends Error {
|
|
5
|
+
constructor(error: RequestError);
|
|
6
|
+
}
|
|
7
|
+
export declare class NonUniquePasswordError extends Error {
|
|
8
|
+
constructor(error: RequestError);
|
|
9
|
+
}
|
|
4
10
|
export declare function patchSession({ session, }: {
|
|
5
11
|
session: PatchSessionModel;
|
|
6
12
|
}): Promise<SessionModel>;
|
|
@@ -26,31 +32,6 @@ export declare function createSession({ accessToken, isGuest, keepMeSignedIn, pa
|
|
|
26
32
|
accessToken: string;
|
|
27
33
|
} & CreateSessionRequestBody): Promise<SessionModel>;
|
|
28
34
|
export declare function signOut(): Promise<void>;
|
|
29
|
-
export declare function createGuestAccount({ defaultWarehouseId, }: {
|
|
30
|
-
defaultWarehouseId: string;
|
|
31
|
-
}): Promise<AccountModel>;
|
|
32
35
|
export declare function recoverPassword({ userName, }: {
|
|
33
36
|
userName: string;
|
|
34
37
|
}): Promise<SessionModel>;
|
|
35
|
-
export declare class ExistingAccountError extends RequestError {
|
|
36
|
-
constructor(error: Error);
|
|
37
|
-
}
|
|
38
|
-
export interface CreateAccountRequestBase {
|
|
39
|
-
email: string;
|
|
40
|
-
firstName?: string;
|
|
41
|
-
isSubscribed: boolean;
|
|
42
|
-
lastName: string;
|
|
43
|
-
password: string;
|
|
44
|
-
}
|
|
45
|
-
export interface CreatePrivateAccountRequestBody extends CreateAccountRequestBase {
|
|
46
|
-
companyName?: string | undefined;
|
|
47
|
-
countryCode: string;
|
|
48
|
-
isPrivateAccount: true;
|
|
49
|
-
}
|
|
50
|
-
export interface CreateBusinessAccountRequestBody extends CreateAccountRequestBase {
|
|
51
|
-
companyName: string;
|
|
52
|
-
countryCode: string;
|
|
53
|
-
isPrivateAccount: false;
|
|
54
|
-
}
|
|
55
|
-
export type CreateAccountRequestBody = CreatePrivateAccountRequestBody | CreateBusinessAccountRequestBody;
|
|
56
|
-
export declare function createAccount({ companyName, countryCode, email, firstName, isPrivateAccount, isSubscribed, lastName, password, }: CreateAccountRequestBody): Promise<AccountModel>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { config } from '../../../../config.js';
|
|
2
|
-
import { request, isRequestError
|
|
2
|
+
import { request, isRequestError } from '../../../fetch/request.js';
|
|
3
3
|
|
|
4
4
|
async function fetchSession() {
|
|
5
5
|
const { body } = await request({
|
|
@@ -8,17 +8,43 @@ async function fetchSession() {
|
|
|
8
8
|
});
|
|
9
9
|
return body;
|
|
10
10
|
}
|
|
11
|
+
class InvalidPasswordError extends Error {
|
|
12
|
+
constructor(error) {
|
|
13
|
+
super(error.body?.message || error.message);
|
|
14
|
+
this.name = 'InvalidPasswordError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
class NonUniquePasswordError extends Error {
|
|
18
|
+
constructor(error) {
|
|
19
|
+
super(error.body?.message || error.message);
|
|
20
|
+
this.name = 'NonUniquePasswordError';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
11
23
|
async function patchSession({ session, }) {
|
|
12
|
-
|
|
13
|
-
body
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
try {
|
|
25
|
+
const { body } = await request({
|
|
26
|
+
body: session,
|
|
27
|
+
credentials: 'include',
|
|
28
|
+
headers: {
|
|
29
|
+
'Content-Type': 'application/json',
|
|
30
|
+
},
|
|
31
|
+
method: 'PATCH',
|
|
32
|
+
url: `${config.SHOP_API_URL}/api/v1/sessions/current`,
|
|
33
|
+
});
|
|
34
|
+
return body;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (isRequestError(error) && error.status === 400) {
|
|
38
|
+
if (error.body?.message ===
|
|
39
|
+
'New Password is required and must be different than Current Password') {
|
|
40
|
+
throw new NonUniquePasswordError(error);
|
|
41
|
+
}
|
|
42
|
+
if (error.body?.message === 'Current Password is invalid') {
|
|
43
|
+
throw new InvalidPasswordError(error);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
22
48
|
}
|
|
23
49
|
async function signIn({ password, userName, }) {
|
|
24
50
|
const params = new URLSearchParams();
|
|
@@ -70,21 +96,6 @@ async function signOut() {
|
|
|
70
96
|
throw error;
|
|
71
97
|
}
|
|
72
98
|
}
|
|
73
|
-
async function createGuestAccount({ defaultWarehouseId, }) {
|
|
74
|
-
const { body } = await request({
|
|
75
|
-
body: {
|
|
76
|
-
defaultFulfillmentMethod: 'Ship',
|
|
77
|
-
defaultWarehouseId,
|
|
78
|
-
isGuest: true,
|
|
79
|
-
},
|
|
80
|
-
headers: {
|
|
81
|
-
'Content-Type': 'application/json',
|
|
82
|
-
},
|
|
83
|
-
method: 'POST',
|
|
84
|
-
url: `${config.SHOP_API_URL}/api/v1/accounts`,
|
|
85
|
-
});
|
|
86
|
-
return body;
|
|
87
|
-
}
|
|
88
99
|
async function recoverPassword({ userName, }) {
|
|
89
100
|
const { body } = await request({
|
|
90
101
|
body: {
|
|
@@ -99,43 +110,5 @@ async function recoverPassword({ userName, }) {
|
|
|
99
110
|
});
|
|
100
111
|
return body;
|
|
101
112
|
}
|
|
102
|
-
class ExistingAccountError extends RequestError {
|
|
103
|
-
constructor(error) {
|
|
104
|
-
super(error);
|
|
105
|
-
this.name = 'ExistingAccountError';
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
async function createAccount({ companyName, countryCode, email, firstName, isPrivateAccount, isSubscribed, lastName, password, }) {
|
|
109
|
-
try {
|
|
110
|
-
const { body } = await request({
|
|
111
|
-
body: {
|
|
112
|
-
email,
|
|
113
|
-
firstName,
|
|
114
|
-
isSubscribed,
|
|
115
|
-
lastName,
|
|
116
|
-
password,
|
|
117
|
-
properties: {
|
|
118
|
-
PrivateAccount: isPrivateAccount,
|
|
119
|
-
companyName,
|
|
120
|
-
countryCode,
|
|
121
|
-
},
|
|
122
|
-
userName: '',
|
|
123
|
-
},
|
|
124
|
-
headers: {
|
|
125
|
-
'Content-Type': 'application/json',
|
|
126
|
-
},
|
|
127
|
-
method: 'POST',
|
|
128
|
-
url: `${config.SHOP_API_URL}/api/v1/accounts`,
|
|
129
|
-
});
|
|
130
|
-
return body;
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
if (isRequestError(error) &&
|
|
134
|
-
error.status === 400 &&
|
|
135
|
-
error.body?.message === 'Email Address already exists')
|
|
136
|
-
throw new ExistingAccountError(error);
|
|
137
|
-
throw error;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
113
|
|
|
141
|
-
export {
|
|
114
|
+
export { InvalidPasswordError, NonUniquePasswordError, createSession, fetchSession, patchSession, recoverPassword, signIn, signOut };
|
|
@@ -3,7 +3,15 @@ import { useState, useEffect } from 'react';
|
|
|
3
3
|
import { getCssPropertyValue } from '../utils/css.js';
|
|
4
4
|
|
|
5
5
|
function useWatchCssProperty(property) {
|
|
6
|
-
const [value, setValue] = useState(() =>
|
|
6
|
+
const [value, setValue] = useState(() => {
|
|
7
|
+
try {
|
|
8
|
+
return getCssPropertyValue(property);
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
// If the property can not be retrieved, return undefined
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
7
15
|
useEffect(() => {
|
|
8
16
|
if (typeof MutationObserver === 'undefined' ||
|
|
9
17
|
typeof document === 'undefined')
|