@vtex/faststore-plugin-buyer-portal 1.1.87 → 1.1.89
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 +39 -28
- package/README.md +2 -2
- package/cypress/constants.ts +1 -1
- package/cypress/integration/collections.test.ts +9 -5
- package/cypress/integration/credit-cards.test.ts +24 -20
- package/cypress/integration/roles.test.ts +3 -1
- package/cypress/support/commands.ts +1 -1
- package/package.json +1 -1
- package/plugin.config.js +20 -20
- package/src/features/addresses/components/AddressForm/AddressForm.tsx +72 -41
- package/src/features/addresses/data/USA.ts +69 -64
- package/src/features/addresses/data/countries.ts +6 -1
- package/src/features/addresses/data/states.ts +4 -2
- package/src/features/addresses/layouts/AddressDetailsLayout/AddressDetailsLayout.tsx +10 -1
- package/src/features/addresses/utils/index.ts +1 -0
- package/src/features/addresses/utils/stateUtils.ts +63 -0
- package/src/features/budgets/components/BudgetAddForm/budget-add-form.scss +9 -3
- package/src/features/budgets/components/BudgetAllocationsSelection/budget-allocations-selection.scss +2 -2
- package/src/features/budgets/components/BudgetAllocationsTable/budget-allocations-table.scss +29 -0
- package/src/features/budgets/components/BudgetDeleteDrawer/budget-delete-drawer.scss +13 -0
- package/src/features/budgets/components/BudgetRemainingBalance/BudgetRemainingBalance.tsx +5 -1
- package/src/features/budgets/components/BudgetRemainingBalance/budget-remaining-balance.scss +18 -1
- package/src/features/budgets/components/BudgetSettingsInfo/budget-settings-info.scss +19 -0
- package/src/features/budgets/components/BudgetsTable/BudgetsTable.tsx +12 -2
- package/src/features/budgets/components/BudgetsTable/budgets-table.scss +30 -1
- package/src/features/budgets/components/CreateBudgetAllocationDrawer/create-budget-allocation-drawer.scss +22 -6
- package/src/features/budgets/components/CreateBudgetDrawer/create-budget-drawer.scss +15 -6
- package/src/features/budgets/components/DeleteBudgetAllocationDrawer/delete-budget-allocations.scss +15 -1
- package/src/features/budgets/components/EditBudgetDrawer/edit-budget-drawer.scss +11 -1
- package/src/features/budgets/layouts/BudgetsDetailsLayout/BudgetsDetailsLayout.tsx +76 -75
- package/src/features/budgets/layouts/BudgetsDetailsLayout/budget-details-layout.scss +22 -19
- package/src/features/budgets/layouts/BudgetsLayout/budgets-layout.scss +6 -0
- package/src/features/buying-policies/components/BasicBuyingPolicyDrawer/basic-buying-policy-drawer.scss +4 -0
- package/src/features/buying-policies/layouts/BuyingPoliciesLayout/buying-policies-layout.scss +41 -6
- package/src/features/buying-policies/layouts/BuyingPolicyDetailsLayout/BuyingPolicyDetailsLayout.tsx +1 -1
- package/src/features/buying-policies/layouts/BuyingPolicyDetailsLayout/buying-policy-details-layout.scss +17 -1
- package/src/features/payment-methods/components/AddPaymentMethodsDrawer/AddPaymentMethodsDrawer.tsx +93 -68
- package/src/features/payment-methods/components/AddPaymentMethodsDrawer/add-payment-methods-drawer.scss +66 -30
- package/src/features/payment-methods/components/SearchPaymentMethods/SearchPaymentMethods.tsx +6 -4
- package/src/features/payment-methods/components/SearchPaymentMethods/search-payment-methods.scss +3 -0
- package/src/features/payment-methods/layouts/PaymentMethodsLayout/PaymentMethodsLayout.tsx +65 -54
- package/src/features/payment-methods/layouts/PaymentMethodsLayout/payment-methods-layout.scss +121 -103
- package/src/features/shared/components/CustomDropdown/custom-dropdown.scss +5 -0
- package/src/features/shared/components/InternalTopbar/InternalTopbar.tsx +1 -1
- package/src/features/shared/components/MainLinksDropdownMenu/MainLinksDropdownMenu.tsx +1 -1
- package/src/features/shared/components/Pagination/Pagination.tsx +18 -8
- package/src/features/shared/components/Pagination/pagination.scss +14 -0
- package/src/features/shared/layouts/BaseTabsLayout/sidebar-drawer/sidebar-drawer.scss +5 -3
- package/src/features/shared/utils/buyerPortalRoutes.ts +1 -1
- package/src/features/shared/utils/routeLayoutMapping.ts +22 -21
- package/src/pages/org-units.tsx +1 -1
- package/src/pages/user-details.tsx +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,62 +7,73 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Added responsiveness to the Payment Methods list.
|
|
13
|
+
- Implemented responsiveness across all drawers in the Payment Methods flow.
|
|
14
|
+
- Ensured responsive behavior for toasts and empty states.
|
|
15
|
+
|
|
10
16
|
### Fixed
|
|
11
|
-
|
|
17
|
+
|
|
18
|
+
- Allow creation of user with no roles
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- Responsiviness to Buying policies page
|
|
12
23
|
|
|
13
24
|
### Added
|
|
14
25
|
|
|
15
|
-
-
|
|
16
|
-
-
|
|
26
|
+
- Credit card page responsiveness
|
|
27
|
+
- Change for the store title based on the SEO
|
|
17
28
|
|
|
18
29
|
### Added
|
|
19
30
|
|
|
20
|
-
-
|
|
31
|
+
- Standardization the sidebar menu throughout the navigation of the Organizational Account, regardless of the context.
|
|
21
32
|
|
|
22
33
|
### Fixed
|
|
23
34
|
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
35
|
+
- Fix geoCordinate to be geoCoordinates
|
|
36
|
+
- Adjusts in Credit Card's experience
|
|
37
|
+
- Create a custom dropdown for Buying Policy criteria
|
|
27
38
|
|
|
28
39
|
### Added
|
|
29
40
|
|
|
30
|
-
-
|
|
41
|
+
- Send credentials
|
|
31
42
|
|
|
32
43
|
### Added
|
|
33
44
|
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
45
|
+
- Roles and Role Details Screen
|
|
46
|
+
- Role Integration on Users
|
|
47
|
+
- Setup lint
|
|
48
|
+
- Add default values for Credit Cards
|
|
38
49
|
|
|
39
50
|
### changed
|
|
40
51
|
|
|
41
|
-
-
|
|
52
|
+
- BFF API URLs
|
|
42
53
|
|
|
43
54
|
### added
|
|
44
55
|
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
56
|
+
- Address Recipients Add & Delete Feature
|
|
57
|
+
- Address Recipients Edit Feature
|
|
58
|
+
- Add Buying Policy integration with BFF
|
|
59
|
+
- Add default values for Address
|
|
49
60
|
|
|
50
61
|
### Fixed
|
|
51
62
|
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
63
|
+
- UserData accepts undefined e-mail
|
|
64
|
+
- Fix styles
|
|
65
|
+
- Fix Address Recipients bff path
|
|
55
66
|
|
|
56
67
|
### Added
|
|
57
68
|
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
69
|
+
- Add Buying Policies Page
|
|
70
|
+
- Add Buying Policy Details Page
|
|
71
|
+
- Add Buying Policy Drawers
|
|
72
|
+
- Add Buying Policy Integrations
|
|
73
|
+
- Add Pagination Tools
|
|
74
|
+
- Add Address Pagination
|
|
64
75
|
|
|
65
76
|
### Added
|
|
66
77
|
|
|
67
|
-
-
|
|
68
|
-
-
|
|
78
|
+
- Add CHANGELOG file
|
|
79
|
+
- Add README file
|
package/README.md
CHANGED
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
- Run `yarn link @vtex/faststore-plugin-buyer-portal`
|
|
15
15
|
- Run `yarn`
|
|
16
16
|
- Run `yarn dev` to start your local server
|
|
17
|
-
- You will acess the
|
|
17
|
+
- You will acess the Organization Account via: localhost:3000/pvt/organization-account
|
|
18
18
|
|
|
19
19
|
### Generating a Cookie
|
|
20
20
|
|
|
21
21
|
- Go to `b2bdev.vtexfaststore.com/login` and log-in as a user that has already been added to an Unit. If you don't have one, contact someone on the B2B - Enabler
|
|
22
22
|
- Go to copy your `VtexIdclientAutCookie_b2bfaststoredev` cookie
|
|
23
23
|
- Create a cookie in your `localhost:3000` with the `VtexIdclientAutCookie_b2bfaststoredev` key and the value you just copied
|
|
24
|
-
- Go to `localhost:3000/
|
|
24
|
+
- Go to `localhost:3000/pvt/organization-account`
|
|
25
25
|
|
|
26
26
|
## Developing
|
|
27
27
|
|
package/cypress/constants.ts
CHANGED
|
@@ -27,11 +27,15 @@ describe("Collections", () => {
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
it("Should show empty state when unit has no collection", () => {
|
|
30
|
-
cy.intercept(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
cy.intercept(
|
|
31
|
+
"GET",
|
|
32
|
+
"/_next/data/**/pvt/organization-account/collections/**",
|
|
33
|
+
(req) => {
|
|
34
|
+
req.reply((res) => {
|
|
35
|
+
res.body.pageProps.data.isContractEmpty = true;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
);
|
|
35
39
|
|
|
36
40
|
visitCollectionsPage();
|
|
37
41
|
|
|
@@ -23,26 +23,30 @@ function interceptCreateCreditCard() {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
function interceptGetCreditCards() {
|
|
26
|
-
cy.intercept(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
26
|
+
cy.intercept(
|
|
27
|
+
"GET",
|
|
28
|
+
"/_next/data/**/pvt/pvt/organization-account/credit-cards/**",
|
|
29
|
+
(req) => {
|
|
30
|
+
req.reply((res) => {
|
|
31
|
+
res.body.pageProps.data.data.push({
|
|
32
|
+
accountId: "FAKE_ACCOUNT_ID",
|
|
33
|
+
paymentSystem: "1",
|
|
34
|
+
paymentSystemName: "Visa",
|
|
35
|
+
cardNumber: "************1234",
|
|
36
|
+
bin: "411111",
|
|
37
|
+
availableAddresses: [],
|
|
38
|
+
expirationDate: "12/2030",
|
|
39
|
+
isExpired: false,
|
|
40
|
+
accountStatus: null,
|
|
41
|
+
cardLabel: "Personal Card",
|
|
42
|
+
useCvvForAuthorization: true,
|
|
43
|
+
isCardToken: false,
|
|
44
|
+
isDefault: false,
|
|
45
|
+
isActive: true,
|
|
46
|
+
});
|
|
43
47
|
});
|
|
44
|
-
}
|
|
45
|
-
|
|
48
|
+
}
|
|
49
|
+
).as("getCreditCards");
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
function fillInitialCreditCardData() {
|
|
@@ -175,7 +179,7 @@ describe("Credit Cards Page", () => {
|
|
|
175
179
|
// Intercept the server-side request and modify only the data field to simulate an empty state
|
|
176
180
|
cy.intercept(
|
|
177
181
|
"GET",
|
|
178
|
-
"/_next/data/**/
|
|
182
|
+
"/_next/data/**/pvt/pvt/organization-account/credit-cards/**",
|
|
179
183
|
(req) => {
|
|
180
184
|
req.reply((res) => {
|
|
181
185
|
res.body.pageProps.data.data = []; // Set the data field to an empty array
|
|
@@ -3,7 +3,9 @@ import { TEST_CONFIG } from "../constants";
|
|
|
3
3
|
// Utility function to navigate to Roles page
|
|
4
4
|
function goToRolesPage() {
|
|
5
5
|
cy.visit(TEST_CONFIG.ROUTES.BUYER_PORTAL);
|
|
6
|
-
cy.get(
|
|
6
|
+
cy.get(
|
|
7
|
+
'a[data-fs-vertical-nav-menu-link][href^="/pvt/organization-account/roles/"]'
|
|
8
|
+
)
|
|
7
9
|
.contains("Roles")
|
|
8
10
|
.click();
|
|
9
11
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TEST_CONFIG } from "../constants";
|
|
2
2
|
|
|
3
3
|
Cypress.Commands.add("login", () => {
|
|
4
|
-
cy.session("
|
|
4
|
+
cy.session("organization-account-login", () => {
|
|
5
5
|
const loginOrigin = new URL(TEST_CONFIG.AUTH.LOGIN_URL).origin;
|
|
6
6
|
const login = Cypress.env("VTEX_ACCOUNT_LOGIN");
|
|
7
7
|
const password = Cypress.env("VTEX_ACCOUNT_PASSWORD");
|
package/package.json
CHANGED
package/plugin.config.js
CHANGED
|
@@ -3,89 +3,89 @@ module.exports = {
|
|
|
3
3
|
name: "poc-plugin",
|
|
4
4
|
pages: {
|
|
5
5
|
home: {
|
|
6
|
-
path: "/
|
|
6
|
+
path: "/pvt/organization-account/[[...contractMode]]",
|
|
7
7
|
appLayout: false,
|
|
8
8
|
},
|
|
9
9
|
"address-details": {
|
|
10
|
-
path: "/
|
|
10
|
+
path: "/pvt/organization-account/address/[orgUnitId]/[contractId]/[addressId]",
|
|
11
11
|
appLayout: false,
|
|
12
12
|
},
|
|
13
13
|
|
|
14
14
|
// ----
|
|
15
15
|
profile: {
|
|
16
|
-
path: "/
|
|
16
|
+
path: "/pvt/organization-account/profile/[orgUnitId]/[contractId]",
|
|
17
17
|
appLayout: false,
|
|
18
18
|
},
|
|
19
19
|
addresses: {
|
|
20
|
-
path: "/
|
|
20
|
+
path: "/pvt/organization-account/addresses/[orgUnitId]/[contractId]",
|
|
21
21
|
appLayout: false,
|
|
22
22
|
},
|
|
23
23
|
budgets: {
|
|
24
|
-
path: "/
|
|
24
|
+
path: "/pvt/organization-account/budgets/[orgUnitId]/[contractId]",
|
|
25
25
|
appLayout: false,
|
|
26
26
|
},
|
|
27
27
|
"budgets-details": {
|
|
28
|
-
path: "/
|
|
28
|
+
path: "/pvt/organization-account/budgets/[orgUnitId]/[contractId]/[budgetId]",
|
|
29
29
|
appLayout: false,
|
|
30
30
|
},
|
|
31
31
|
"payment-methods": {
|
|
32
|
-
path: "/
|
|
32
|
+
path: "/pvt/organization-account/payment-methods/[orgUnitId]/[contractId]",
|
|
33
33
|
appLayout: false,
|
|
34
34
|
},
|
|
35
35
|
"credit-cards": {
|
|
36
|
-
path: "/
|
|
36
|
+
path: "/pvt/organization-account/credit-cards/[orgUnitId]/[contractId]",
|
|
37
37
|
appLayout: false,
|
|
38
38
|
},
|
|
39
39
|
collections: {
|
|
40
|
-
path: "/
|
|
40
|
+
path: "/pvt/organization-account/collections/[orgUnitId]/[contractId]",
|
|
41
41
|
appLayout: false,
|
|
42
42
|
},
|
|
43
43
|
"po-numbers": {
|
|
44
|
-
path: "/
|
|
44
|
+
path: "/pvt/organization-account/po-numbers/[orgUnitId]/[contractId]",
|
|
45
45
|
appLayout: false,
|
|
46
46
|
},
|
|
47
47
|
"cost-centers": {
|
|
48
|
-
path: "/
|
|
48
|
+
path: "/pvt/organization-account/cost-centers/[orgUnitId]/[contractId]",
|
|
49
49
|
appLayout: false,
|
|
50
50
|
},
|
|
51
51
|
releases: {
|
|
52
|
-
path: "/
|
|
52
|
+
path: "/pvt/organization-account/releases/[orgUnitId]/[contractId]",
|
|
53
53
|
appLayout: false,
|
|
54
54
|
},
|
|
55
55
|
roles: {
|
|
56
|
-
path: "/
|
|
56
|
+
path: "/pvt/organization-account/roles/[orgUnitId]",
|
|
57
57
|
appLayout: false,
|
|
58
58
|
},
|
|
59
59
|
"role-details": {
|
|
60
|
-
path: "/
|
|
60
|
+
path: "/pvt/organization-account/roles/[orgUnitId]/[roleName]",
|
|
61
61
|
appLayout: false,
|
|
62
62
|
},
|
|
63
63
|
"buying-policies": {
|
|
64
|
-
path: "/
|
|
64
|
+
path: "/pvt/organization-account/buying-policies/[orgUnitId]/[contractId]",
|
|
65
65
|
appLayout: false,
|
|
66
66
|
},
|
|
67
67
|
|
|
68
68
|
"buying-policy-details": {
|
|
69
|
-
path: "/
|
|
69
|
+
path: "/pvt/organization-account/buying-policy/[orgUnitId]/[contractId]/[buyingPolicyId]",
|
|
70
70
|
appLayout: false,
|
|
71
71
|
},
|
|
72
72
|
|
|
73
73
|
users: {
|
|
74
|
-
path: "/
|
|
74
|
+
path: "/pvt/organization-account/users/[orgUnitId]",
|
|
75
75
|
appLayout: false,
|
|
76
76
|
},
|
|
77
77
|
|
|
78
78
|
"org-units": {
|
|
79
|
-
path: "/
|
|
79
|
+
path: "/pvt/organization-account/org-units/[orgUnitId]",
|
|
80
80
|
appLayout: false,
|
|
81
81
|
},
|
|
82
82
|
|
|
83
83
|
"user-details": {
|
|
84
|
-
path: "/
|
|
84
|
+
path: "/pvt/organization-account/user/[orgUnitId]/[userId]",
|
|
85
85
|
appLayout: false,
|
|
86
86
|
},
|
|
87
87
|
"org-unit-details": {
|
|
88
|
-
path: "/
|
|
88
|
+
path: "/pvt/organization-account/org-unit/[orgUnitId]",
|
|
89
89
|
appLayout: false,
|
|
90
90
|
},
|
|
91
91
|
},
|
|
@@ -9,10 +9,17 @@ import {
|
|
|
9
9
|
} from "../../../shared/components";
|
|
10
10
|
import { useBuyerPortal } from "../../../shared/hooks";
|
|
11
11
|
import { maskPostalCode } from "../../../shared/utils/postalCode";
|
|
12
|
-
import { CountryOptions } from "../../data/countries";
|
|
13
|
-
import { states as StateOptions } from "../../data/states";
|
|
12
|
+
import { CountryOptions, type CountryOption } from "../../data/countries";
|
|
14
13
|
import { useDebouncedSearchAddress } from "../../hooks/useDebouncedSearchAddress";
|
|
15
14
|
import { AddressData, AddressInput } from "../../types";
|
|
15
|
+
import {
|
|
16
|
+
getStateDisplayValue,
|
|
17
|
+
getStateSaveValue,
|
|
18
|
+
isStateSelected,
|
|
19
|
+
getStateDisplayOptions,
|
|
20
|
+
findStateByDisplayValue,
|
|
21
|
+
getStateDisplayFromCode,
|
|
22
|
+
} from "../../utils";
|
|
16
23
|
|
|
17
24
|
export type AddressFormProps = {
|
|
18
25
|
address: AddressInput;
|
|
@@ -42,7 +49,11 @@ export const AddressForm = ({
|
|
|
42
49
|
}: AddressFormProps) => {
|
|
43
50
|
const addressTypeOptions = ["Shipping", "Billing"];
|
|
44
51
|
const { currentOrgUnit } = useBuyerPortal();
|
|
45
|
-
|
|
52
|
+
const [selectedState, setSelectedState] = useState(
|
|
53
|
+
address.state
|
|
54
|
+
? getStateDisplayFromCode(address.countryCode || "", address.state)
|
|
55
|
+
: ""
|
|
56
|
+
);
|
|
46
57
|
const [autoCompleteAddressName, setAutoCompleteAddressName] = useState("");
|
|
47
58
|
|
|
48
59
|
const { searchedAddresses } = useDebouncedSearchAddress(
|
|
@@ -66,6 +77,16 @@ export const AddressForm = ({
|
|
|
66
77
|
|
|
67
78
|
const hideLabel = isEdit || fixedType;
|
|
68
79
|
|
|
80
|
+
const handleCountrySelect = (option: CountryOption) => {
|
|
81
|
+
setAddress({
|
|
82
|
+
...address,
|
|
83
|
+
country: option.name,
|
|
84
|
+
countryCode: option.id,
|
|
85
|
+
state: "",
|
|
86
|
+
});
|
|
87
|
+
setSelectedState("");
|
|
88
|
+
};
|
|
89
|
+
|
|
69
90
|
return (
|
|
70
91
|
<>
|
|
71
92
|
{!useExistingAddress ? (
|
|
@@ -79,26 +100,18 @@ export const AddressForm = ({
|
|
|
79
100
|
value={address.country}
|
|
80
101
|
options={CountryOptions}
|
|
81
102
|
shouldCloseOnSelect
|
|
82
|
-
onConfirmKeyPress={(option) =>
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
country: option.name,
|
|
86
|
-
countryCode: option.id,
|
|
87
|
-
})
|
|
88
|
-
}
|
|
103
|
+
onConfirmKeyPress={(option) => {
|
|
104
|
+
handleCountrySelect(option);
|
|
105
|
+
}}
|
|
89
106
|
renderOption={(option, index) => (
|
|
90
107
|
<AutocompleteDropdown.Item
|
|
91
108
|
key={option.id}
|
|
92
109
|
closeOnClick
|
|
93
110
|
index={index}
|
|
94
111
|
isSelected={address.country === option.name}
|
|
95
|
-
onClick={() =>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
country: option.name,
|
|
99
|
-
countryCode: option.id,
|
|
100
|
-
})
|
|
101
|
-
}
|
|
112
|
+
onClick={() => {
|
|
113
|
+
handleCountrySelect(option);
|
|
114
|
+
}}
|
|
102
115
|
>
|
|
103
116
|
{option?.name}
|
|
104
117
|
{address.country === option?.name && (
|
|
@@ -218,32 +231,50 @@ export const AddressForm = ({
|
|
|
218
231
|
data-fs-bp-create-address-state-selector
|
|
219
232
|
label="State"
|
|
220
233
|
className="address-state"
|
|
221
|
-
value={
|
|
222
|
-
options={
|
|
223
|
-
address.countryCode ? StateOptions[address.countryCode] : []
|
|
224
|
-
}
|
|
234
|
+
value={selectedState}
|
|
235
|
+
options={getStateDisplayOptions(address.countryCode || "")}
|
|
225
236
|
shouldCloseOnSelect
|
|
226
|
-
onConfirmKeyPress={(option) =>
|
|
227
|
-
|
|
228
|
-
|
|
237
|
+
onConfirmKeyPress={(option) => {
|
|
238
|
+
const stateData = findStateByDisplayValue(
|
|
239
|
+
address.countryCode || "",
|
|
240
|
+
option
|
|
241
|
+
);
|
|
242
|
+
if (stateData) {
|
|
243
|
+
setSelectedState(option);
|
|
244
|
+
setAddress({ ...address, state: getStateSaveValue(stateData) });
|
|
245
|
+
}
|
|
246
|
+
}}
|
|
229
247
|
disabled={!address.countryCode}
|
|
230
|
-
renderOption={(option, index) =>
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
248
|
+
renderOption={(option, index) => {
|
|
249
|
+
const stateData = findStateByDisplayValue(
|
|
250
|
+
address.countryCode || "",
|
|
251
|
+
option
|
|
252
|
+
);
|
|
253
|
+
const isSelected = stateData
|
|
254
|
+
? isStateSelected(address.state, stateData)
|
|
255
|
+
: false;
|
|
256
|
+
|
|
257
|
+
return (
|
|
258
|
+
<AutocompleteDropdown.Item
|
|
259
|
+
key={`${option}-${index}`}
|
|
260
|
+
closeOnClick
|
|
261
|
+
index={index}
|
|
262
|
+
isSelected={isSelected}
|
|
263
|
+
onClick={() => {
|
|
264
|
+
if (stateData) {
|
|
265
|
+
setSelectedState(getStateDisplayValue(stateData));
|
|
266
|
+
setAddress({
|
|
267
|
+
...address,
|
|
268
|
+
state: getStateSaveValue(stateData),
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}}
|
|
272
|
+
>
|
|
273
|
+
{option}
|
|
274
|
+
{isSelected && <Icon name="Check" width={12} height={12} />}
|
|
275
|
+
</AutocompleteDropdown.Item>
|
|
276
|
+
);
|
|
277
|
+
}}
|
|
247
278
|
/>
|
|
248
279
|
|
|
249
280
|
<InputText
|
|
@@ -1,65 +1,70 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
1
|
+
export type StateOption = {
|
|
2
|
+
code: string;
|
|
3
|
+
name: string;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export const states: StateOption[] = [
|
|
7
|
+
{ code: "AL", name: "Alabama" },
|
|
8
|
+
{ code: "AK", name: "Alaska" },
|
|
9
|
+
{ code: "AS", name: "American Samoa" },
|
|
10
|
+
{ code: "AZ", name: "Arizona" },
|
|
11
|
+
{ code: "AR", name: "Arkansas" },
|
|
12
|
+
{ code: "AA", name: "Armed Forces Americas" },
|
|
13
|
+
{ code: "AE", name: "Armed Forces Europe, the Middle East, and Canada" },
|
|
14
|
+
{ code: "AP", name: "Armed Forces Pacific" },
|
|
15
|
+
{ code: "CA", name: "California" },
|
|
16
|
+
{ code: "CO", name: "Colorado" },
|
|
17
|
+
{ code: "CT", name: "Connecticut" },
|
|
18
|
+
{ code: "DE", name: "Delaware" },
|
|
19
|
+
{ code: "DC", name: "District Of Columbia (Washington, D.C.)" },
|
|
20
|
+
{ code: "FM", name: "Federated States of Micronesia" },
|
|
21
|
+
{ code: "FL", name: "Florida" },
|
|
22
|
+
{ code: "GA", name: "Georgia" },
|
|
23
|
+
{ code: "GU", name: "Guam" },
|
|
24
|
+
{ code: "HI", name: "Hawaii" },
|
|
25
|
+
{ code: "ID", name: "Idaho" },
|
|
26
|
+
{ code: "IL", name: "Illinois" },
|
|
27
|
+
{ code: "IN", name: "Indiana" },
|
|
28
|
+
{ code: "IA", name: "Iowa" },
|
|
29
|
+
{ code: "KS", name: "Kansas" },
|
|
30
|
+
{ code: "KY", name: "Kentucky" },
|
|
31
|
+
{ code: "LA", name: "Louisiana" },
|
|
32
|
+
{ code: "ME", name: "Maine" },
|
|
33
|
+
{ code: "MH", name: "Marshall Islands" },
|
|
34
|
+
{ code: "MD", name: "Maryland" },
|
|
35
|
+
{ code: "MA", name: "Massachusetts" },
|
|
36
|
+
{ code: "MI", name: "Michigan" },
|
|
37
|
+
{ code: "MN", name: "Minnesota" },
|
|
38
|
+
{ code: "MS", name: "Mississippi" },
|
|
39
|
+
{ code: "MO", name: "Missouri" },
|
|
40
|
+
{ code: "MT", name: "Montana" },
|
|
41
|
+
{ code: "NE", name: "Nebraska" },
|
|
42
|
+
{ code: "NV", name: "Nevada" },
|
|
43
|
+
{ code: "NH", name: "New Hampshire" },
|
|
44
|
+
{ code: "NJ", name: "New Jersey" },
|
|
45
|
+
{ code: "NM", name: "New Mexico" },
|
|
46
|
+
{ code: "NY", name: "New York" },
|
|
47
|
+
{ code: "NC", name: "North Carolina" },
|
|
48
|
+
{ code: "ND", name: "North Dakota" },
|
|
49
|
+
{ code: "MP", name: "Northern Mariana Islands" },
|
|
50
|
+
{ code: "OH", name: "Ohio" },
|
|
51
|
+
{ code: "OK", name: "Oklahoma" },
|
|
52
|
+
{ code: "OR", name: "Oregon" },
|
|
53
|
+
{ code: "PW", name: "Palau" },
|
|
54
|
+
{ code: "PA", name: "Pennsylvania" },
|
|
55
|
+
{ code: "PR", name: "Puerto Rico" },
|
|
56
|
+
{ code: "RI", name: "Rhode Island" },
|
|
57
|
+
{ code: "SC", name: "South Carolina" },
|
|
58
|
+
{ code: "SD", name: "South Dakota" },
|
|
59
|
+
{ code: "TN", name: "Tennessee" },
|
|
60
|
+
{ code: "TX", name: "Texas" },
|
|
61
|
+
{ code: "UM", name: "U.S. Minor Outlying Islands" },
|
|
62
|
+
{ code: "VI", name: "U.S. Virgin Islands" },
|
|
63
|
+
{ code: "UT", name: "Utah" },
|
|
64
|
+
{ code: "VT", name: "Vermont" },
|
|
65
|
+
{ code: "VA", name: "Virginia" },
|
|
66
|
+
{ code: "WA", name: "Washington" },
|
|
67
|
+
{ code: "WV", name: "West Virginia" },
|
|
68
|
+
{ code: "WI", name: "Wisconsin" },
|
|
69
|
+
{ code: "WY", name: "Wyoming" },
|
|
65
70
|
];
|