@sonic-equipment/ui 229.0.0 → 231.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/pages/account/sign-in-page/sign-in-page.js +1 -1
- package/dist/pages/checkout/shipping-page/components/readonly-address.js +14 -2
- package/dist/shared/api/storefront/hooks/authentication/use-sign-in.js +3 -0
- package/dist/shared/api/storefront/services/authentication-service.d.ts +2 -2
- package/dist/shared/api/storefront/services/authentication-service.js +4 -3
- package/dist/shared/fetch/request.d.ts +3 -1
- package/dist/shared/fetch/request.js +14 -0
- package/package.json +1 -1
|
@@ -94,7 +94,7 @@ function SignInPage({ returnUrl } = {}) {
|
|
|
94
94
|
userName: userName || '',
|
|
95
95
|
}, { onSuccess: onSignInSuccess });
|
|
96
96
|
};
|
|
97
|
-
return (jsxs(Fragment, { children: [jsx(SignInPageLayout, { fullHeight: true, "data-test-selector": "signInPage", children: jsx(SignInForm, { allowGuestSignIn: allowGuestSignIn, createAccountPath: createAccountPath, errorType: signInErrorType, initialEmail: session?.isGuest ? '' : session?.email, initialRememberMe: session?.rememberMe, isDisabled: !session || isSuccess, isLoading: isLoading, isPendingGuestSignIn: isPendingCreateGuest, isPendingUserSignIn: isPendingSignIn, onRecoverPasswordDialogOpen: () => setRecoverPasswordDialogOpen(true), onSubmit: onSignIn }) }), jsx(RecoverPasswordDialog, { isOpen: isRecoverPasswordDialogOpen, onOpenChange: isOpen => setRecoverPasswordDialogOpen(isOpen) }), jsx(ChangePasswordDialog, { allowClose:
|
|
97
|
+
return (jsxs(Fragment, { children: [jsx(SignInPageLayout, { fullHeight: true, "data-test-selector": "signInPage", children: jsx(SignInForm, { allowGuestSignIn: allowGuestSignIn, createAccountPath: createAccountPath, errorType: signInErrorType, initialEmail: session?.isGuest ? '' : session?.email, initialRememberMe: session?.rememberMe, isDisabled: !session || isSuccess, isLoading: isLoading, isPendingGuestSignIn: isPendingCreateGuest, isPendingUserSignIn: isPendingSignIn, onRecoverPasswordDialogOpen: () => setRecoverPasswordDialogOpen(true), onSubmit: onSignIn }) }), jsx(RecoverPasswordDialog, { isOpen: isRecoverPasswordDialogOpen, onOpenChange: isOpen => setRecoverPasswordDialogOpen(isOpen) }), jsx(ChangePasswordDialog, { allowClose: true, error: errorChangePassword, informationalText: t('You are required to change your password and then sign in again, using your new credentials.'), isOpen: isChangePasswordDialogOpen, isUpdating: isSessionUpdating, onClose: () => setChangePasswordDialogOpen(false), onPasswordChanged: onChangePassword, userName: userName })] }));
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
export { SignInPage };
|
|
@@ -7,7 +7,9 @@ import { Checkbox } from '../../../../forms/elements/checkbox/checkbox.js';
|
|
|
7
7
|
import { TextField } from '../../../../forms/fields/text-field/text-field.js';
|
|
8
8
|
import { FormattedMessage } from '../../../../intl/formatted-message.js';
|
|
9
9
|
import { useFormattedMessage } from '../../../../intl/use-formatted-message.js';
|
|
10
|
+
import { useLocation } from '../../../../shared/routing/use-location.js';
|
|
10
11
|
import { usePaths } from '../../../../shared/routing/use-paths.js';
|
|
12
|
+
import { environment } from '../../../../shared/utils/environment.js';
|
|
11
13
|
import { CheckoutPageSection } from '../../layouts/checkout-page-layout/components/checkout-page-section.js';
|
|
12
14
|
import { CheckoutPageSectionContent } from '../../layouts/checkout-page-layout/components/checkout-page-section-content.js';
|
|
13
15
|
import { CheckoutPageSectionLink } from '../../layouts/checkout-page-layout/components/checkout-page-section-link.js';
|
|
@@ -18,6 +20,16 @@ import styles from './readonly-address.module.css.js';
|
|
|
18
20
|
function ReadOnlyAddresses({ billTo, isLoading, isPickup, notes, onSubmit, shipTo, }) {
|
|
19
21
|
const t = useFormattedMessage();
|
|
20
22
|
const paths = usePaths();
|
|
23
|
+
const { pathname, search } = useLocation();
|
|
24
|
+
const href = `${pathname}${search}`;
|
|
25
|
+
const billToId = billTo?.id;
|
|
26
|
+
const shipToId = shipTo?.id;
|
|
27
|
+
const editBillToAddressUrl = environment === 'next'
|
|
28
|
+
? `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/${billToId}?returnUrl=${encodeURIComponent(href)}`
|
|
29
|
+
: paths.ACCOUNT_ADDRESSES;
|
|
30
|
+
const editShipToAddressUrl = environment === 'next'
|
|
31
|
+
? `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/${billToId}${paths.ACCOUNT_EDIT_SHIP_TO_ADDRESS}/${shipToId}?returnUrl=${encodeURIComponent(href)}`
|
|
32
|
+
: paths.ACCOUNT_ADDRESSES;
|
|
21
33
|
return (jsxs(Form, { id: EDIT_ADDRESS_FORM_ID, onSubmit: e => {
|
|
22
34
|
e.preventDefault();
|
|
23
35
|
const formData = new FormData(e.currentTarget);
|
|
@@ -26,7 +38,7 @@ function ReadOnlyAddresses({ billTo, isLoading, isPickup, notes, onSubmit, shipT
|
|
|
26
38
|
? undefined
|
|
27
39
|
: formData.get('notes')?.toString() || '',
|
|
28
40
|
});
|
|
29
|
-
}, children: [jsxs(CheckoutPageSection, { title: jsx(FormattedMessage, { id: "Billing address" }), children: [jsx(CheckoutPageSectionLink, { children: jsxs(Link, { color: "secondary", href:
|
|
41
|
+
}, children: [jsxs(CheckoutPageSection, { title: jsx(FormattedMessage, { id: "Billing address" }), children: [jsx(CheckoutPageSectionLink, { children: jsxs(Link, { color: "secondary", href: editBillToAddressUrl, isDisabled: isLoading, children: [jsx(FormattedMessage, { id: "Edit billing address" }), " >"] }) }), jsxs(CheckoutPageSectionContent, { children: [billTo && (jsx(AddressInfoDisplay, { address: {
|
|
30
42
|
address1: billTo.address1,
|
|
31
43
|
address2: billTo.address2,
|
|
32
44
|
address3: billTo.address3,
|
|
@@ -39,7 +51,7 @@ function ReadOnlyAddresses({ billTo, isLoading, isPickup, notes, onSubmit, shipT
|
|
|
39
51
|
lastName: billTo.lastName,
|
|
40
52
|
phone: billTo.phone,
|
|
41
53
|
postalCode: billTo.postalCode,
|
|
42
|
-
}, "data-test-selector": "billToAddress" })), jsx("div", { className: styles.notes, children: jsx(TextField, { defaultValue: notes, isDisabled: isLoading, isMultiline: true, label: t('Add order notes'), name: "notes", rows: 3, showLabel: true }) })] })] }), jsxs(CheckoutPageSection, { title: jsx(FormattedMessage, { id: isPickup ? 'Pickup address' : 'Shipping address' }), children: [!isPickup && (jsx(CheckoutPageSectionLink, { children: jsxs(Link, { color: "secondary", href:
|
|
54
|
+
}, "data-test-selector": "billToAddress" })), jsx("div", { className: styles.notes, children: jsx(TextField, { defaultValue: notes, isDisabled: isLoading, isMultiline: true, label: t('Add order notes'), name: "notes", rows: 3, showLabel: true }) })] })] }), jsxs(CheckoutPageSection, { title: jsx(FormattedMessage, { id: isPickup ? 'Pickup address' : 'Shipping address' }), children: [!isPickup && (jsx(CheckoutPageSectionLink, { children: jsxs(Link, { color: "secondary", href: editShipToAddressUrl, isDisabled: isLoading, children: [jsx(FormattedMessage, { id: "Edit shipping address" }), " >"] }) })), jsx(CheckoutPageSectionContent, { children: isPickup ? (jsx(SonicAddress, {})) : (jsxs(Fragment, { children: [jsx(Checkbox, { className: styles['use-invoice-checkbox'], "data-test-selector": "checkboxUseBillingAddress", isDisabled: true, isSelected: true, children: jsx(FormattedMessage, { id: "Use billing address" }) }), shipTo && (jsx(AddressInfoDisplay, { address: {
|
|
43
55
|
address1: shipTo.address1,
|
|
44
56
|
address2: shipTo.address2,
|
|
45
57
|
address3: shipTo.address3,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useQueryClient, useMutation } from '@tanstack/react-query';
|
|
3
|
+
import { UnprocessableContentRequestError } from '../../../../fetch/request.js';
|
|
3
4
|
import { signIn, createSession, InvalidGrantError } from '../../services/authentication-service.js';
|
|
4
5
|
|
|
5
6
|
function useSignIn() {
|
|
@@ -18,6 +19,8 @@ function useSignIn() {
|
|
|
18
19
|
return body;
|
|
19
20
|
}
|
|
20
21
|
catch (error) {
|
|
22
|
+
if (error instanceof UnprocessableContentRequestError)
|
|
23
|
+
throw error;
|
|
21
24
|
if (error instanceof InvalidGrantError)
|
|
22
25
|
throw error;
|
|
23
26
|
queryClient.resetQueries();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BadRequestError, RequestError } from '../../../fetch/request';
|
|
1
|
+
import { BadRequestError, RequestError, RequestReturnType } from '../../../fetch/request';
|
|
2
2
|
import { APIArguments } from '../../shared/types';
|
|
3
3
|
import { PatchSessionModel, SessionModel } from '../model/storefront.model';
|
|
4
4
|
export declare function fetchSession(args?: APIArguments): Promise<SessionModel>;
|
|
@@ -47,7 +47,7 @@ export interface CreateSessionRequestBody {
|
|
|
47
47
|
export declare function createSession({ accessToken, isGuest, keepMeSignedIn, password, rememberMe, returnUrl, userName, }: {
|
|
48
48
|
accessToken: string;
|
|
49
49
|
} & CreateSessionRequestBody): Promise<SessionModel>;
|
|
50
|
-
export declare function signOut(): Promise<
|
|
50
|
+
export declare function signOut(args?: APIArguments): Promise<RequestReturnType<unknown>>;
|
|
51
51
|
export declare function recoverPassword({ userName, }: {
|
|
52
52
|
userName: string;
|
|
53
53
|
}): Promise<SessionModel>;
|
|
@@ -144,16 +144,17 @@ async function createSession({ accessToken, isGuest, keepMeSignedIn, password, r
|
|
|
144
144
|
throw error;
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
async function signOut() {
|
|
147
|
+
async function signOut(args) {
|
|
148
148
|
try {
|
|
149
|
-
await request({
|
|
149
|
+
return await request({
|
|
150
|
+
headers: args?.headers,
|
|
150
151
|
method: 'DELETE',
|
|
151
152
|
url: `${config.SHOP_API_URL}/api/v1/sessions/current`,
|
|
152
153
|
});
|
|
153
154
|
}
|
|
154
155
|
catch (error) {
|
|
155
156
|
if (error instanceof UnauthorizedRequestError)
|
|
156
|
-
return;
|
|
157
|
+
return error.response;
|
|
157
158
|
throw error;
|
|
158
159
|
}
|
|
159
160
|
}
|
|
@@ -22,6 +22,7 @@ export declare class RequestError extends Error {
|
|
|
22
22
|
status: number;
|
|
23
23
|
statusText?: string;
|
|
24
24
|
body?: any;
|
|
25
|
+
response?: Response;
|
|
25
26
|
context?: string;
|
|
26
27
|
options?: RequestOptions;
|
|
27
28
|
constructor(responseOrError: Response | any, options?: RequestErrorOptions, status?: number, statusText?: string);
|
|
@@ -32,7 +33,8 @@ export declare class BadRequestError extends RequestError {
|
|
|
32
33
|
constructor(responseOrError: Response | unknown, options?: RequestErrorOptions);
|
|
33
34
|
}
|
|
34
35
|
export declare class UnauthorizedRequestError extends RequestError {
|
|
35
|
-
|
|
36
|
+
response: Response;
|
|
37
|
+
constructor(responseOrError: Response, options?: RequestErrorOptions);
|
|
36
38
|
}
|
|
37
39
|
export declare class ForbiddenRequestError extends RequestError {
|
|
38
40
|
constructor(responseOrError: Response | unknown, options?: RequestErrorOptions);
|
|
@@ -37,6 +37,12 @@ class RequestError extends Error {
|
|
|
37
37
|
writable: true,
|
|
38
38
|
value: void 0
|
|
39
39
|
});
|
|
40
|
+
Object.defineProperty(this, "response", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
configurable: true,
|
|
43
|
+
writable: true,
|
|
44
|
+
value: void 0
|
|
45
|
+
});
|
|
40
46
|
Object.defineProperty(this, "context", {
|
|
41
47
|
enumerable: true,
|
|
42
48
|
configurable: true,
|
|
@@ -52,6 +58,7 @@ class RequestError extends Error {
|
|
|
52
58
|
if (isResponse(responseOrError)) {
|
|
53
59
|
this.status = responseOrError.status || status || -1;
|
|
54
60
|
this.statusText = responseOrError.statusText || statusText;
|
|
61
|
+
this.response = responseOrError;
|
|
55
62
|
}
|
|
56
63
|
else {
|
|
57
64
|
this.status = -1;
|
|
@@ -92,7 +99,14 @@ class BadRequestError extends RequestError {
|
|
|
92
99
|
class UnauthorizedRequestError extends RequestError {
|
|
93
100
|
constructor(responseOrError, options) {
|
|
94
101
|
super(responseOrError, options, 401, 'unauthorized');
|
|
102
|
+
Object.defineProperty(this, "response", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
configurable: true,
|
|
105
|
+
writable: true,
|
|
106
|
+
value: void 0
|
|
107
|
+
});
|
|
95
108
|
this.name = 'UnauthorizedRequestError';
|
|
109
|
+
this.response = responseOrError;
|
|
96
110
|
}
|
|
97
111
|
}
|
|
98
112
|
class ForbiddenRequestError extends RequestError {
|