@vtex/faststore-plugin-buyer-portal 1.3.2 → 1.3.4
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/CHANGELOG.md +19 -3
- package/package.json +1 -1
- package/src/features/addresses/clients/AddressesClient.ts +1 -1
- package/src/features/addresses/components/AddressForm/AddressForm.tsx +15 -0
- package/src/features/addresses/components/AddressInfoDisplay/AddressInfoDisplay.tsx +1 -0
- package/src/features/addresses/components/CreateAddressDrawer/CreateAddressDrawer.tsx +7 -1
- package/src/features/addresses/components/EditAddressDrawer/EditAddressDrawer.tsx +4 -1
- package/src/features/shared/components/Error/error.scss +6 -0
- package/src/features/shared/types/AuthRouteProps.ts +15 -2
- package/src/features/shared/utils/constants.ts +1 -1
- package/src/features/shared/utils/withAuth.tsx +19 -7
- package/src/features/shared/utils/withAuthLoader.ts +15 -3
- package/src/features/shared/utils/withAuthProvider.tsx +15 -5
package/CHANGELOG.md
CHANGED
|
@@ -7,12 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
## [1.3.
|
|
10
|
+
## [1.3.4] - 2025-10-16
|
|
11
|
+
|
|
12
|
+
- Error boundary:
|
|
13
|
+
- Updating the authentication loader to provide detailed error context.
|
|
14
|
+
|
|
15
|
+
## [1.3.3] - 2025-10-16
|
|
11
16
|
|
|
12
17
|
### Added
|
|
13
18
|
|
|
19
|
+
- Neighborhood field to Address form
|
|
20
|
+
- Added `neighborhood` field to address creation and editing forms
|
|
21
|
+
- Updated `AddressForm` component to include neighborhood input
|
|
22
|
+
- Updated `AddressInfoDisplay` to show neighborhood information
|
|
23
|
+
- Updated `CreateAddressDrawer` and `EditAddressDrawer` to handle neighborhood data
|
|
24
|
+
- Updated `AddressesClient` to support neighborhood field in API requests
|
|
14
25
|
- Setup KeepChangelog
|
|
15
26
|
|
|
27
|
+
## [1.3.2] - 2025-10-16
|
|
28
|
+
|
|
16
29
|
## [1.2.4] - 2025-10-16
|
|
17
30
|
|
|
18
31
|
### Added
|
|
@@ -107,9 +120,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
107
120
|
- Add CHANGELOG file
|
|
108
121
|
- Add README file
|
|
109
122
|
|
|
110
|
-
[unreleased]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/1.3.
|
|
123
|
+
[unreleased]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/1.3.4...HEAD
|
|
111
124
|
[1.2.3]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.2.2...1.2.3
|
|
112
125
|
[1.2.3]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.2.3
|
|
113
126
|
[1.2.4]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.2.4
|
|
114
|
-
|
|
115
127
|
[1.3.2]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.3.2
|
|
128
|
+
|
|
129
|
+
[1.3.3]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.3.3
|
|
130
|
+
|
|
131
|
+
[1.3.4]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.3.4
|
package/package.json
CHANGED
|
@@ -138,7 +138,7 @@ export default class AddressesClient extends Client {
|
|
|
138
138
|
streetAddress: data.streetAddress,
|
|
139
139
|
neighborhood: data?.neighborhood ?? "",
|
|
140
140
|
streetAddress2: data.streetAddress2,
|
|
141
|
-
|
|
141
|
+
streetNumber: data.streetNumber ?? "",
|
|
142
142
|
city: data.city,
|
|
143
143
|
state: data.state,
|
|
144
144
|
country: data.countryCode,
|
|
@@ -210,6 +210,21 @@ export const AddressForm = ({
|
|
|
210
210
|
show={isTouched && !address.streetNumber?.trim()}
|
|
211
211
|
message="Number is required"
|
|
212
212
|
/>
|
|
213
|
+
|
|
214
|
+
<InputText
|
|
215
|
+
label="Neighborhood"
|
|
216
|
+
value={address.neighborhood || ""}
|
|
217
|
+
className="address-neighborhood"
|
|
218
|
+
hasError={isTouched && !address.neighborhood?.trim()}
|
|
219
|
+
onChange={(event) =>
|
|
220
|
+
setAddress({ ...address, neighborhood: event.target.value })
|
|
221
|
+
}
|
|
222
|
+
/>
|
|
223
|
+
|
|
224
|
+
<ErrorMessage
|
|
225
|
+
show={isTouched && !address.neighborhood?.trim()}
|
|
226
|
+
message="Neighborhood is required"
|
|
227
|
+
/>
|
|
213
228
|
</>
|
|
214
229
|
)}
|
|
215
230
|
|
|
@@ -15,6 +15,7 @@ const AddressDisplay: React.FC<AddressDisplayProps> = ({
|
|
|
15
15
|
{option?.streetAddress}
|
|
16
16
|
{option?.streetAddress2 && `, ${option?.streetAddress2}`}
|
|
17
17
|
{option?.streetNumber && ` ${option?.streetNumber}`}
|
|
18
|
+
{option?.neighborhood && `, ${option?.neighborhood}`}
|
|
18
19
|
{option?.unit && ` ${option?.unit}`}
|
|
19
20
|
{option?.city && `, ${option?.city}`}
|
|
20
21
|
{option?.state && `, ${option?.state}`}
|
|
@@ -110,7 +110,13 @@ export const CreateAddressDrawer = ({
|
|
|
110
110
|
const hasBrazilianNumber =
|
|
111
111
|
!isBrazil || (isBrazil && address.streetNumber?.trim());
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
const hasBrazilianNeighborhood =
|
|
114
|
+
!isBrazil || (isBrazil && address.neighborhood?.trim());
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
(hasRequiredFields && hasBrazilianNumber && hasBrazilianNeighborhood) ||
|
|
118
|
+
useExistingAddress
|
|
119
|
+
);
|
|
114
120
|
};
|
|
115
121
|
|
|
116
122
|
const isConfirmButtonEnabled = hasMinimumAddressInformation();
|
|
@@ -75,7 +75,10 @@ export const EditAddressDrawer = ({
|
|
|
75
75
|
const hasBrazilianNumber =
|
|
76
76
|
!isBrazil || (isBrazil && address.streetNumber?.trim());
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
const hasBrazilianNeighborhood =
|
|
79
|
+
!isBrazil || (isBrazil && address.neighborhood?.trim());
|
|
80
|
+
|
|
81
|
+
return hasRequiredFields && hasBrazilianNumber && hasBrazilianNeighborhood;
|
|
79
82
|
};
|
|
80
83
|
|
|
81
84
|
const isConfirmButtonEnabled = hasMinimumAddressInformation();
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
padding: var(--fs-spacing-4);
|
|
34
34
|
border-radius: var(--fs-border-radius-medium);
|
|
35
35
|
position: relative;
|
|
36
|
+
max-width: 100%;
|
|
36
37
|
|
|
37
38
|
[data-fs-bp-error-details-type] {
|
|
38
39
|
position: absolute;
|
|
@@ -56,6 +57,7 @@
|
|
|
56
57
|
font-weight: var(--fs-text-weight-medium);
|
|
57
58
|
color: #e2e2e2;
|
|
58
59
|
text-wrap: wrap;
|
|
60
|
+
overflow-wrap: break-word;
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
[data-fs-bp-error-details-stack] {
|
|
@@ -63,12 +65,16 @@
|
|
|
63
65
|
margin: var(--fs-spacing-4) 0;
|
|
64
66
|
font-weight: var(--fs-text-weight-medium);
|
|
65
67
|
text-wrap: wrap;
|
|
68
|
+
max-width: 100%;
|
|
69
|
+
overflow-wrap: break-word;
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
[data-fs-bp-error-details-component] {
|
|
69
73
|
font-size: var(--fs-text-size-2);
|
|
70
74
|
font-weight: var(--fs-text-weight-medium);
|
|
71
75
|
text-wrap: wrap;
|
|
76
|
+
overflow-wrap: break-word;
|
|
77
|
+
max-width: 100%;
|
|
72
78
|
}
|
|
73
79
|
}
|
|
74
80
|
}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
+
import { ErrorBoundaryProps } from "../components/ErrorBoundary/types";
|
|
1
2
|
import { ClientContext } from "../utils";
|
|
2
3
|
|
|
3
4
|
export type AuthRouteProps<T> =
|
|
4
|
-
| {
|
|
5
|
-
|
|
5
|
+
| {
|
|
6
|
+
authorized: true;
|
|
7
|
+
data: T;
|
|
8
|
+
clientContext: ClientContext;
|
|
9
|
+
hasError?: boolean;
|
|
10
|
+
error?: ErrorBoundaryProps;
|
|
11
|
+
}
|
|
12
|
+
| {
|
|
13
|
+
authorized: false;
|
|
14
|
+
hasError?: boolean;
|
|
15
|
+
error?: ErrorBoundaryProps;
|
|
16
|
+
data?: T;
|
|
17
|
+
clientContext?: ClientContext;
|
|
18
|
+
};
|
|
@@ -2,30 +2,42 @@ import { useEffect, type ComponentType } from "react";
|
|
|
2
2
|
|
|
3
3
|
import { useRouter } from "next/router";
|
|
4
4
|
|
|
5
|
+
import { ErrorBoundaryProps } from "../components/ErrorBoundary/types";
|
|
6
|
+
|
|
5
7
|
import type { AuthRouteProps } from "../types";
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* HOC that checks only for authorization
|
|
9
11
|
*/
|
|
10
12
|
export const withAuth = <T extends Record<string, unknown>>(
|
|
11
|
-
Component: ComponentType<T>
|
|
13
|
+
Component: ComponentType<T & { hasError?: boolean }>
|
|
12
14
|
) => {
|
|
13
|
-
return function AuthenticatedComponent(
|
|
15
|
+
return function AuthenticatedComponent(
|
|
16
|
+
props: AuthRouteProps<T> & {
|
|
17
|
+
hasError?: boolean;
|
|
18
|
+
error?: ErrorBoundaryProps;
|
|
19
|
+
}
|
|
20
|
+
) {
|
|
14
21
|
const router = useRouter();
|
|
15
22
|
|
|
16
23
|
useEffect(() => {
|
|
17
24
|
// If not authorized, reload the page
|
|
18
|
-
if (!props?.authorized) {
|
|
25
|
+
if (!props?.authorized && !props?.hasError) {
|
|
19
26
|
router.reload();
|
|
20
27
|
}
|
|
21
|
-
}, [props?.authorized, router]);
|
|
28
|
+
}, [props?.authorized, props?.hasError, router]);
|
|
22
29
|
|
|
23
|
-
|
|
24
|
-
if (!props?.authorized) {
|
|
30
|
+
if (!props?.authorized && !props?.hasError && !props?.error) {
|
|
25
31
|
return null;
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
// If authorized, render the component with the data
|
|
29
|
-
return
|
|
35
|
+
return (
|
|
36
|
+
<Component
|
|
37
|
+
{...(props.data as T)}
|
|
38
|
+
hasError={props?.hasError}
|
|
39
|
+
error={props?.error}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
30
42
|
};
|
|
31
43
|
};
|
|
@@ -37,11 +37,23 @@ export const withAuthLoader = async <T>(
|
|
|
37
37
|
} catch (error) {
|
|
38
38
|
console.error("Auth validation failed:", error);
|
|
39
39
|
|
|
40
|
-
data.res?.writeHead(302, { Location: "/" });
|
|
41
|
-
data.res?.end();
|
|
42
|
-
|
|
43
40
|
return {
|
|
44
41
|
authorized: false,
|
|
42
|
+
hasError: true,
|
|
43
|
+
error: {
|
|
44
|
+
error: {
|
|
45
|
+
message: (error as Error).message,
|
|
46
|
+
name: (error as Error).name,
|
|
47
|
+
stack: (error as Error).stack || undefined,
|
|
48
|
+
},
|
|
49
|
+
extra: {
|
|
50
|
+
query: data.query,
|
|
51
|
+
},
|
|
52
|
+
tags: {
|
|
53
|
+
component: "AuthLoader",
|
|
54
|
+
errorType: "auth_error",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
45
57
|
};
|
|
46
58
|
}
|
|
47
59
|
};
|
|
@@ -3,6 +3,7 @@ import { useEffect, type ComponentType } from "react";
|
|
|
3
3
|
import { useRouter } from "next/router";
|
|
4
4
|
|
|
5
5
|
import { BuyerPortalProvider } from "../components";
|
|
6
|
+
import { ErrorBoundaryProps } from "../components/ErrorBoundary/types";
|
|
6
7
|
|
|
7
8
|
import type { AuthRouteProps } from "../types";
|
|
8
9
|
import type { ClientContext } from "./getClientContext";
|
|
@@ -13,7 +14,12 @@ import type { ClientContext } from "./getClientContext";
|
|
|
13
14
|
export const withAuthProvider = <T,>(
|
|
14
15
|
Component: ComponentType<T & { clientContext: ClientContext }>
|
|
15
16
|
) => {
|
|
16
|
-
return function WrappedPage(
|
|
17
|
+
return function WrappedPage(
|
|
18
|
+
props: AuthRouteProps<T> & {
|
|
19
|
+
hasError?: boolean;
|
|
20
|
+
error?: ErrorBoundaryProps;
|
|
21
|
+
}
|
|
22
|
+
) {
|
|
17
23
|
const router = useRouter();
|
|
18
24
|
|
|
19
25
|
useEffect(() => {
|
|
@@ -23,14 +29,18 @@ export const withAuthProvider = <T,>(
|
|
|
23
29
|
}
|
|
24
30
|
}, [props?.authorized, router]);
|
|
25
31
|
|
|
26
|
-
|
|
27
|
-
if (!props?.authorized) {
|
|
32
|
+
if (!props?.authorized && !props?.hasError && !props?.error) {
|
|
28
33
|
return null;
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
return (
|
|
32
|
-
<BuyerPortalProvider
|
|
33
|
-
|
|
37
|
+
<BuyerPortalProvider
|
|
38
|
+
clientContext={props?.clientContext as ClientContext}
|
|
39
|
+
>
|
|
40
|
+
<Component
|
|
41
|
+
{...(props.data as T)}
|
|
42
|
+
clientContext={props?.clientContext as ClientContext}
|
|
43
|
+
/>
|
|
34
44
|
</BuyerPortalProvider>
|
|
35
45
|
);
|
|
36
46
|
};
|