@vtex/faststore-plugin-buyer-portal 1.1.99 → 1.1.101

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/faststore-plugin-buyer-portal",
3
- "version": "1.1.99",
3
+ "version": "1.1.101",
4
4
  "description": "A plugin for faststore with buyer portal",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -104,6 +104,7 @@ export default class AddressesClient extends Client {
104
104
  streetAddress: data.streetAddress,
105
105
  neighborhood: data?.neighborhood ?? "",
106
106
  streetAddress2: data.streetAddress2,
107
+ streetNumber: data.streetNumber ?? "",
107
108
  city: data.city,
108
109
  state: data.state,
109
110
  country: data.countryCode,
@@ -137,6 +138,7 @@ export default class AddressesClient extends Client {
137
138
  streetAddress: data.streetAddress,
138
139
  neighborhood: data?.neighborhood ?? "",
139
140
  streetAddress2: data.streetAddress2,
141
+ number: data.streetNumber ?? "",
140
142
  city: data.city,
141
143
  state: data.state,
142
144
  country: data.countryCode,
@@ -193,6 +193,26 @@ export const AddressForm = ({
193
193
  message="Street Address is required"
194
194
  />
195
195
 
196
+ {address.countryCode === "BRA" && (
197
+ <>
198
+ <InputText
199
+ type="number"
200
+ label="Number"
201
+ value={address.streetNumber || ""}
202
+ className="address-number"
203
+ hasError={isTouched && !address.streetNumber?.trim()}
204
+ onChange={(event) =>
205
+ setAddress({ ...address, streetNumber: event.target.value })
206
+ }
207
+ />
208
+
209
+ <ErrorMessage
210
+ show={isTouched && !address.streetNumber?.trim()}
211
+ message="Number is required"
212
+ />
213
+ </>
214
+ )}
215
+
196
216
  <InputText
197
217
  label="Apt, Suite, Building (optional)"
198
218
  className="street-address2"
@@ -97,16 +97,20 @@ export const CreateAddressDrawer = ({
97
97
  };
98
98
 
99
99
  const hasMinimumAddressInformation = () => {
100
- return (
101
- (address.name &&
102
- address.streetAddress &&
103
- address.country &&
104
- address.zip &&
105
- address.state &&
106
- address.city &&
107
- address.types.length > 0) ||
108
- useExistingAddress
109
- );
100
+ const isBrazil = address.countryCode === "BRA";
101
+ const hasRequiredFields =
102
+ address.name &&
103
+ address.streetAddress &&
104
+ address.country &&
105
+ address.zip &&
106
+ address.state &&
107
+ address.city &&
108
+ address.types.length > 0;
109
+
110
+ const hasBrazilianNumber =
111
+ !isBrazil || (isBrazil && address.streetNumber?.trim());
112
+
113
+ return (hasRequiredFields && hasBrazilianNumber) || useExistingAddress;
110
114
  };
111
115
 
112
116
  const isConfirmButtonEnabled = hasMinimumAddressInformation();
@@ -62,15 +62,20 @@ export const EditAddressDrawer = ({
62
62
  };
63
63
 
64
64
  const hasMinimumAddressInformation = () => {
65
- return (
65
+ const isBrazil = address.countryCode === "BRA";
66
+ const hasRequiredFields =
66
67
  address.name &&
67
68
  address.streetAddress &&
68
69
  address.country &&
69
70
  address.zip &&
70
71
  address.state &&
71
72
  address.city &&
72
- address.types.length > 0
73
- );
73
+ address.types.length > 0;
74
+
75
+ const hasBrazilianNumber =
76
+ !isBrazil || (isBrazil && address.streetNumber?.trim());
77
+
78
+ return hasRequiredFields && hasBrazilianNumber;
74
79
  };
75
80
 
76
81
  const isConfirmButtonEnabled = hasMinimumAddressInformation();
@@ -10,6 +10,7 @@ export type AddressOption = {
10
10
  streetAddress: string;
11
11
  streetAddress2: string;
12
12
  streetNumber: string;
13
+ number?: string;
13
14
  unit: string;
14
15
  neighborhood?: string;
15
16
  city: string;
@@ -89,6 +90,7 @@ export type AddressInput = {
89
90
  name: string;
90
91
  streetAddress: string;
91
92
  streetAddress2: string;
93
+ streetNumber?: string;
92
94
  country: string;
93
95
  countryCode: string;
94
96
  zip: string;
@@ -174,16 +174,20 @@ export const CreateCreditCardDrawer = ({
174
174
  };
175
175
 
176
176
  const hasMinimumAddressInformation = () => {
177
- return (
178
- (address.name &&
179
- address.streetAddress &&
180
- address.country &&
181
- address.zip &&
182
- address.state &&
183
- address.city &&
184
- address.types.length > 0) ||
185
- useExistingAddress
186
- );
177
+ const isBrazil = address.countryCode === "BRA";
178
+ const hasRequiredFields =
179
+ address.name &&
180
+ address.streetAddress &&
181
+ address.country &&
182
+ address.zip &&
183
+ address.state &&
184
+ address.city &&
185
+ address.types.length > 0;
186
+
187
+ const hasBrazilianNumber =
188
+ !isBrazil || (isBrazil && address.streetNumber?.trim());
189
+
190
+ return (hasRequiredFields && hasBrazilianNumber) || useExistingAddress;
187
191
  };
188
192
 
189
193
  const hasCardInformation = () => {
@@ -29,7 +29,7 @@ export const tokenizeCreditCardService = async ({
29
29
  neighborhood: creditCard.address.neighborhood ?? "",
30
30
  geoCoordinates: creditCard.address.geoCoordinates.split(",") ?? [],
31
31
  postalCode: creditCard.address.zip,
32
- number: "",
32
+ number: creditCard.address.streetNumber ?? "",
33
33
  receiverName: "NOT EMPTY",
34
34
  reference: "",
35
35
  state: creditCard.address.state,
@@ -1,7 +1,7 @@
1
1
  export const addressLabelToPropMapping = {
2
2
  name: "Address Name",
3
3
  streetAddress: "Street address",
4
- streetNumber: "Street Number",
4
+ streetNumber: "Number",
5
5
  streetAddress2: "Apt, Suite, Building",
6
6
  country: "Country",
7
7
  zip: "Postal Code",
@@ -34,6 +34,5 @@ export {
34
34
  export { toQueryParams } from "./toQueryParams";
35
35
  export { getValidPage } from "./getValidPage";
36
36
  export { isPluginError } from "./isPluginError";
37
- export { useRouteTabsLayoutWithRetry } from "./routeLayoutMapping";
38
37
  export { withLoaderErrorBoundary } from "./withLoaderErrorBoundary";
39
38
  export { withClientErrorBoundary } from "./withClientErrorBoundary";