@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.
Files changed (52) hide show
  1. package/CHANGELOG.md +39 -28
  2. package/README.md +2 -2
  3. package/cypress/constants.ts +1 -1
  4. package/cypress/integration/collections.test.ts +9 -5
  5. package/cypress/integration/credit-cards.test.ts +24 -20
  6. package/cypress/integration/roles.test.ts +3 -1
  7. package/cypress/support/commands.ts +1 -1
  8. package/package.json +1 -1
  9. package/plugin.config.js +20 -20
  10. package/src/features/addresses/components/AddressForm/AddressForm.tsx +72 -41
  11. package/src/features/addresses/data/USA.ts +69 -64
  12. package/src/features/addresses/data/countries.ts +6 -1
  13. package/src/features/addresses/data/states.ts +4 -2
  14. package/src/features/addresses/layouts/AddressDetailsLayout/AddressDetailsLayout.tsx +10 -1
  15. package/src/features/addresses/utils/index.ts +1 -0
  16. package/src/features/addresses/utils/stateUtils.ts +63 -0
  17. package/src/features/budgets/components/BudgetAddForm/budget-add-form.scss +9 -3
  18. package/src/features/budgets/components/BudgetAllocationsSelection/budget-allocations-selection.scss +2 -2
  19. package/src/features/budgets/components/BudgetAllocationsTable/budget-allocations-table.scss +29 -0
  20. package/src/features/budgets/components/BudgetDeleteDrawer/budget-delete-drawer.scss +13 -0
  21. package/src/features/budgets/components/BudgetRemainingBalance/BudgetRemainingBalance.tsx +5 -1
  22. package/src/features/budgets/components/BudgetRemainingBalance/budget-remaining-balance.scss +18 -1
  23. package/src/features/budgets/components/BudgetSettingsInfo/budget-settings-info.scss +19 -0
  24. package/src/features/budgets/components/BudgetsTable/BudgetsTable.tsx +12 -2
  25. package/src/features/budgets/components/BudgetsTable/budgets-table.scss +30 -1
  26. package/src/features/budgets/components/CreateBudgetAllocationDrawer/create-budget-allocation-drawer.scss +22 -6
  27. package/src/features/budgets/components/CreateBudgetDrawer/create-budget-drawer.scss +15 -6
  28. package/src/features/budgets/components/DeleteBudgetAllocationDrawer/delete-budget-allocations.scss +15 -1
  29. package/src/features/budgets/components/EditBudgetDrawer/edit-budget-drawer.scss +11 -1
  30. package/src/features/budgets/layouts/BudgetsDetailsLayout/BudgetsDetailsLayout.tsx +76 -75
  31. package/src/features/budgets/layouts/BudgetsDetailsLayout/budget-details-layout.scss +22 -19
  32. package/src/features/budgets/layouts/BudgetsLayout/budgets-layout.scss +6 -0
  33. package/src/features/buying-policies/components/BasicBuyingPolicyDrawer/basic-buying-policy-drawer.scss +4 -0
  34. package/src/features/buying-policies/layouts/BuyingPoliciesLayout/buying-policies-layout.scss +41 -6
  35. package/src/features/buying-policies/layouts/BuyingPolicyDetailsLayout/BuyingPolicyDetailsLayout.tsx +1 -1
  36. package/src/features/buying-policies/layouts/BuyingPolicyDetailsLayout/buying-policy-details-layout.scss +17 -1
  37. package/src/features/payment-methods/components/AddPaymentMethodsDrawer/AddPaymentMethodsDrawer.tsx +93 -68
  38. package/src/features/payment-methods/components/AddPaymentMethodsDrawer/add-payment-methods-drawer.scss +66 -30
  39. package/src/features/payment-methods/components/SearchPaymentMethods/SearchPaymentMethods.tsx +6 -4
  40. package/src/features/payment-methods/components/SearchPaymentMethods/search-payment-methods.scss +3 -0
  41. package/src/features/payment-methods/layouts/PaymentMethodsLayout/PaymentMethodsLayout.tsx +65 -54
  42. package/src/features/payment-methods/layouts/PaymentMethodsLayout/payment-methods-layout.scss +121 -103
  43. package/src/features/shared/components/CustomDropdown/custom-dropdown.scss +5 -0
  44. package/src/features/shared/components/InternalTopbar/InternalTopbar.tsx +1 -1
  45. package/src/features/shared/components/MainLinksDropdownMenu/MainLinksDropdownMenu.tsx +1 -1
  46. package/src/features/shared/components/Pagination/Pagination.tsx +18 -8
  47. package/src/features/shared/components/Pagination/pagination.scss +14 -0
  48. package/src/features/shared/layouts/BaseTabsLayout/sidebar-drawer/sidebar-drawer.scss +5 -3
  49. package/src/features/shared/utils/buyerPortalRoutes.ts +1 -1
  50. package/src/features/shared/utils/routeLayoutMapping.ts +22 -21
  51. package/src/pages/org-units.tsx +1 -1
  52. package/src/pages/user-details.tsx +1 -1
@@ -1,4 +1,9 @@
1
- export const CountryOptions = [
1
+ export type CountryOption = {
2
+ id: string;
3
+ name: string;
4
+ };
5
+
6
+ export const CountryOptions: CountryOption[] = [
2
7
  { id: "BRA", name: "Brazil" },
3
8
  { id: "USA", name: "United States of America" },
4
9
  { id: "CAN", name: "Canada" },
@@ -1,9 +1,11 @@
1
1
  import { states as BRAStates } from "./BRA";
2
2
  import { states as CANStates } from "./CAN";
3
3
  import { states as MEXStates } from "./MEX";
4
- import { states as USAStates } from "./USA";
4
+ import { states as USAStates, StateOption } from "./USA";
5
5
 
6
- export const states: Record<string, string[]> = {
6
+ export type StateData = string | StateOption;
7
+
8
+ export const states: Record<string, StateData[]> = {
7
9
  MEX: MEXStates,
8
10
  BRA: BRAStates,
9
11
  USA: USAStates,
@@ -22,6 +22,7 @@ import {
22
22
  } from "../../components";
23
23
  import { AddressLocationsList } from "../../components/AddressLocationsList/AddressLocationsList";
24
24
  import { AddressRecipientsList } from "../../components/AddressRecipientsList/AddressRecipientsList";
25
+ import { getStateDisplayFromCode } from "../../utils";
25
26
 
26
27
  import type { AddressLocationsListRef } from "../../components/AddressLocationsList/AddressLocationsList";
27
28
  import type { AddressRecipientsListRef } from "../../components/AddressRecipientsList/AddressRecipientsList";
@@ -154,6 +155,14 @@ export const AddressDetailsLayout = ({
154
155
  {props
155
156
  .filter((prop) => addressData[prop])
156
157
  .map((prop, index) => {
158
+ const displayValue =
159
+ prop === "state"
160
+ ? getStateDisplayFromCode(
161
+ addressData.country || "",
162
+ addressData[prop] as string
163
+ )
164
+ : addressData[prop];
165
+
157
166
  return (
158
167
  <div
159
168
  key={prop}
@@ -164,7 +173,7 @@ export const AddressDetailsLayout = ({
164
173
  {addressLabelToPropMapping[prop]}
165
174
  </span>
166
175
  <span data-fs-address-details-info-line-value>
167
- {addressData[prop]}
176
+ {displayValue}
168
177
  </span>
169
178
  </div>
170
179
  );
@@ -0,0 +1 @@
1
+ export * from "./stateUtils";
@@ -0,0 +1,63 @@
1
+ import { states as StateOptions, StateData } from "../data/states";
2
+ import { StateOption } from "../data/USA";
3
+
4
+ export const getStateDisplayValue = (stateData: StateData): string => {
5
+ return typeof stateData === "string" ? stateData : stateData.name;
6
+ };
7
+
8
+ export const getStateSaveValue = (stateData: StateData): string => {
9
+ return typeof stateData === "string" ? stateData : stateData.code;
10
+ };
11
+
12
+ export const isStateSelected = (
13
+ currentState: string,
14
+ stateData: StateData
15
+ ): boolean => {
16
+ const saveValue = getStateSaveValue(stateData);
17
+ return currentState.toLowerCase() === saveValue.toLowerCase();
18
+ };
19
+
20
+ export const getStateDisplayOptions = (countryCode: string): string[] => {
21
+ if (!countryCode || !StateOptions[countryCode]) {
22
+ return [];
23
+ }
24
+ return StateOptions[countryCode].map(getStateDisplayValue);
25
+ };
26
+
27
+ export const getStateOptions = (countryCode: string): StateData[] => {
28
+ if (!countryCode || !StateOptions[countryCode]) {
29
+ return [];
30
+ }
31
+ return StateOptions[countryCode];
32
+ };
33
+
34
+ export const findStateByDisplayValue = (
35
+ countryCode: string,
36
+ displayValue: string
37
+ ): StateData | undefined => {
38
+ const stateOptions = getStateOptions(countryCode);
39
+ return stateOptions.find(
40
+ (state) => getStateDisplayValue(state) === displayValue
41
+ );
42
+ };
43
+
44
+ export const getStateDisplayFromCode = (
45
+ countryCode: string,
46
+ stateCode: string
47
+ ): string => {
48
+ if (!countryCode || !stateCode || !StateOptions[countryCode]) {
49
+ return stateCode;
50
+ }
51
+
52
+ const stateOptions = StateOptions[countryCode];
53
+
54
+ if (countryCode === "USA") {
55
+ const stateOption = stateOptions.find((state) => {
56
+ const option = state as StateOption;
57
+ return option.code?.toLowerCase() === stateCode.toLowerCase();
58
+ });
59
+ return stateOption ? getStateDisplayValue(stateOption) : stateCode;
60
+ }
61
+
62
+ return stateCode;
63
+ };
@@ -12,10 +12,14 @@
12
12
  }
13
13
  [data-fs-bp-create-budget-drawer-row-section] {
14
14
  display: flex;
15
- flex-direction: row;
15
+ flex-direction: column;
16
16
  width: 100%;
17
- align-items: center;
18
- gap: var(--fs-spacing-3);
17
+
18
+ @include media(">=notebook") {
19
+ align-items: center;
20
+ flex-direction: row;
21
+ gap: var(--fs-spacing-3);
22
+ }
19
23
  }
20
24
 
21
25
  [data-fs-bp-create-budget-drawer-data-section] {
@@ -26,6 +30,8 @@
26
30
  [data-fs-bp-create-budget-renew] {
27
31
  margin-top: var(--fs-spacing-4);
28
32
  justify-content: space-between;
33
+ flex-direction: row;
34
+
29
35
  [data-fs-bp-create-budget-renew-label] {
30
36
  font-weight: var(--fs-text-weight-regular);
31
37
  font-size: var(--fs-text-size-1);
@@ -116,7 +116,7 @@
116
116
  [data-fs-table-row="true"] {
117
117
  [data-fs-table-cell="header"] {
118
118
  height: var(--fs-spacing-6);
119
- padding: 0;
119
+ padding: 0 var(--fs-spacing-1);
120
120
 
121
121
  font-weight: var(--fs-text-weight-regular);
122
122
  color: #5c5c5c;
@@ -142,7 +142,7 @@
142
142
  font-weight: var(--fs-text-weight-medium);
143
143
  color: #1f1f1f;
144
144
  font-size: var(--fs-text-size-1);
145
- padding: 0;
145
+ padding: var(--fs-spacing-1);
146
146
 
147
147
  &:nth-child(1) {
148
148
  width: var(--fs-spacing-6);
@@ -70,6 +70,12 @@
70
70
  margin-bottom: var(--fs-spacing-4);
71
71
  justify-content: space-between;
72
72
  align-items: center;
73
+
74
+ @include media("<tablet") {
75
+ [data-fs-buyer-portal-internal-search] {
76
+ width: 100%;
77
+ }
78
+ }
73
79
  }
74
80
 
75
81
  [data-fs-bp-pagination-span] {
@@ -111,6 +117,10 @@
111
117
  font-size: var(--fs-text-size-1);
112
118
  padding: 0;
113
119
 
120
+ @include media("<tablet") {
121
+ padding: 0 var(--fs-spacing-1);
122
+ }
123
+
114
124
  [data-fs-icon] {
115
125
  display: inline-block;
116
126
 
@@ -145,6 +155,20 @@
145
155
  }
146
156
  }
147
157
 
158
+ [data-fs-table-cell] {
159
+ @include media("<tablet") {
160
+ display: none;
161
+
162
+ &:first-child {
163
+ display: flex;
164
+ }
165
+
166
+ &:last-child {
167
+ display: table-cell;
168
+ }
169
+ }
170
+ }
171
+
148
172
  [data-fs-skeleton] {
149
173
  display: inline-block;
150
174
  }
@@ -154,5 +178,10 @@
154
178
  width: 32rem;
155
179
  text-align: center;
156
180
  margin: 0 auto;
181
+
182
+ @include media("<tablet") {
183
+ width: 100%;
184
+ padding: var(--fs-spacing-4);
185
+ }
157
186
  }
158
187
  }
@@ -4,6 +4,19 @@
4
4
  @import "../../../shared/components/InputText/input-text.scss";
5
5
  @import "../../../shared/components/ErrorMessage/error-message.scss";
6
6
 
7
+ &[data-fs-bp-basic-drawer][data-fs-slide-over-size="partial"] {
8
+ width: 100%;
9
+ max-width: none;
10
+
11
+ @include media(">=tablet") {
12
+ max-width: 30rem;
13
+ }
14
+
15
+ @include media(">=notebook") {
16
+ max-width: 40rem;
17
+ }
18
+ }
19
+
7
20
  [data-fs-bp-basic-drawer-body] {
8
21
  overflow-y: auto;
9
22
  }
@@ -25,8 +25,12 @@ export const BudgetRemainingBalance = ({
25
25
  of {formatCurrency(remaining)} used
26
26
  </span>
27
27
  </span>
28
+ <BudgetProgressBar
29
+ remaining={remaining}
30
+ total={total}
31
+ fullWidth={true}
32
+ />
28
33
  </div>
29
- <BudgetProgressBar remaining={remaining} total={total} fullWidth={true} />
30
34
  </div>
31
35
  );
32
36
  };
@@ -8,11 +8,28 @@
8
8
  }
9
9
 
10
10
  [data-fs-bp-budget-remaining-balance-header-content] {
11
- display: flex;
11
+ display: grid;
12
+ grid-template-columns: 1fr auto;
12
13
  justify-content: space-between;
13
14
  align-items: baseline;
15
+ gap: var(--fs-spacing-3);
16
+
14
17
  margin-bottom: var(--fs-spacing-3);
15
18
 
19
+ @include media("<tablet") {
20
+ grid-template-columns: 1fr;
21
+ gap: var(--fs-spacing-2);
22
+ }
23
+
24
+ [data-fs-bp-budgets-progress-bar] {
25
+ grid-column: span 2;
26
+
27
+ @include media("<tablet") {
28
+ grid-column: 1;
29
+ grid-row: 2;
30
+ }
31
+ }
32
+
16
33
  [data-fs-bp-budget-remaining-balance-label-remaining] {
17
34
  font-weight: var(--fs-text-weight-semibold);
18
35
  font-size: var(--fs-text-size-6);
@@ -12,6 +12,12 @@
12
12
 
13
13
  [data-fs-bp-budget-settings-divider] {
14
14
  border: calc(var(--fs-border-width) / 2) solid #e0e0e0;
15
+
16
+ &:first-of-type {
17
+ @include media("<tablet") {
18
+ border: none;
19
+ }
20
+ }
15
21
  }
16
22
 
17
23
  [data-fs-bp-budget-settings-details-row] {
@@ -21,17 +27,30 @@
21
27
  font-size: var(--fs-text-size-1);
22
28
  line-height: calc(var(--fs-spacing-3) + var(--fs-spacing-0));
23
29
 
30
+ @include media("<tablet") {
31
+ flex-direction: column;
32
+ padding: var(--fs-spacing-2) 0;
33
+ }
34
+
24
35
  [data-fs-bp-budget-settings-details-row-label] {
25
36
  width: 12.5rem;
26
37
  color: #707070;
27
38
  font-size: var(--fs-text-size-1);
28
39
  font-weight: var(--fs-text-weight-regular);
40
+
41
+ @include media("<tablet") {
42
+ font-size: var(--fs-text-size-0);
43
+ }
29
44
  }
30
45
 
31
46
  [data-fs-bp-budget-settings-details-row-value] {
32
47
  color: #000;
33
48
  font-size: var(--fs-text-size-1);
34
49
  font-weight: var(--fs-text-weight-medium);
50
+
51
+ @include media("<tablet") {
52
+ font-weight: var(--fs-text-weight-regular);
53
+ }
35
54
  }
36
55
  }
37
56
 
@@ -48,6 +48,7 @@ export function BudgetsTable({
48
48
  </TableCell>
49
49
  <TableCell
50
50
  data-fs-table-cell-width
51
+ data-fs-bp-cell-remaining
51
52
  scope="col"
52
53
  variant="data"
53
54
  align="left"
@@ -57,7 +58,12 @@ export function BudgetsTable({
57
58
  <TableCell scope="col" variant="data" align="center">
58
59
  Expiration date
59
60
  </TableCell>
60
- <TableCell scope="col" variant="data" align="center">
61
+ <TableCell
62
+ scope="col"
63
+ variant="data"
64
+ align="center"
65
+ data-fs-bp-cell-currency
66
+ >
61
67
  Total (USD)
62
68
  </TableCell>
63
69
  <TableCell scope="col" variant="data" align="right" />
@@ -95,7 +101,11 @@ export function BudgetsTable({
95
101
  new Date(item.expirationDate)
96
102
  )}
97
103
  </TableCell>
98
- <TableCell align="center" data-fs-bp-text-medium>
104
+ <TableCell
105
+ align="center"
106
+ data-fs-bp-text-medium
107
+ data-fs-bp-cell-currency
108
+ >
99
109
  {formatCurrency(item.total)}
100
110
  </TableCell>
101
111
  <TableCell
@@ -6,7 +6,7 @@
6
6
  [data-fs-table] {
7
7
  overflow-x: visible;
8
8
  }
9
- [data-fs-bp-table-row]{
9
+ [data-fs-bp-table-row] {
10
10
  cursor: pointer;
11
11
  }
12
12
 
@@ -64,6 +64,35 @@
64
64
  cursor: pointer;
65
65
  align-items: center;
66
66
  }
67
+
68
+ @include media("<tablet") {
69
+ [data-fs-table-cell] {
70
+ display: none;
71
+
72
+ &:first-child {
73
+ display: flex;
74
+ }
75
+
76
+ &:last-child {
77
+ display: table-cell;
78
+ padding-right: 0;
79
+ }
80
+ }
81
+ }
82
+
83
+ @include media("<notebook") {
84
+ [data-fs-table-cell="data"]:not(:first-of-type) {
85
+ text-align: right;
86
+ }
87
+
88
+ [data-fs-bp-cell-remaining] {
89
+ opacity: 0;
90
+ }
91
+
92
+ [data-fs-bp-cell-currency] {
93
+ display: none;
94
+ }
95
+ }
67
96
  }
68
97
  [data-fs-table-cell-width] {
69
98
  width: 13.75rem;
@@ -16,24 +16,36 @@
16
16
  }
17
17
 
18
18
  &[data-fs-bp-basic-drawer] {
19
- max-width: 60rem !important;
20
19
  width: 100% !important;
20
+ max-width: none !important;
21
+
22
+ @include media(">=tablet") {
23
+ max-width: 32rem !important;
24
+ }
25
+
26
+ @include media(">=notebook") {
27
+ max-width: 60rem !important;
28
+ width: 100% !important;
29
+ }
30
+
21
31
  & > [data-fs-bp-basic-drawer-footer] {
22
32
  justify-content: flex-end !important;
23
33
  gap: var(--fs-spacing-1);
24
34
  }
25
- }
26
35
 
27
- [data-fs-bp-create-budget-drawer-step-success="true"] {
28
- border-bottom: none !important;
29
- }
30
- &[data-fs-bp-basic-drawer] {
31
36
  [data-fs-bp-create-budget-drawer-header-arrow] {
32
37
  display: flex;
33
38
  flex-direction: row;
34
39
  align-items: center;
35
40
  gap: var(--fs-spacing-3);
36
41
  cursor: pointer;
42
+
43
+ @include media("<tablet") {
44
+ [data-fs-icon] {
45
+ width: var(--fs-spacing-3);
46
+ height: var(--fs-spacing-3);
47
+ }
48
+ }
37
49
  }
38
50
 
39
51
  [data-fs-bp-basic-drawer-button-variant="confirm"][disabled] {
@@ -45,6 +57,10 @@
45
57
  }
46
58
  }
47
59
 
60
+ [data-fs-bp-create-budget-drawer-step-success="true"] {
61
+ border-bottom: none !important;
62
+ }
63
+
48
64
  [data-fs-bp-basic-drawer-button-variant="confirm"][disabled] {
49
65
  background-color: #0068d7;
50
66
  cursor: not-allowed;
@@ -17,18 +17,23 @@
17
17
  }
18
18
 
19
19
  &[data-fs-bp-basic-drawer] {
20
- max-width: 60rem !important;
21
20
  width: 100% !important;
21
+ max-width: none !important;
22
+
23
+ @include media(">=tablet") {
24
+ max-width: 30rem !important;
25
+ min-width: 30rem !important;
26
+ }
27
+
28
+ @include media(">=notebook") {
29
+ max-width: 40rem !important;
30
+ }
31
+
22
32
  & > [data-fs-bp-basic-drawer-footer] {
23
33
  justify-content: flex-end !important;
24
34
  gap: var(--fs-spacing-1);
25
35
  }
26
- }
27
36
 
28
- [data-fs-bp-create-budget-drawer-step-success="true"] {
29
- border-bottom: none !important;
30
- }
31
- &[data-fs-bp-basic-drawer] {
32
37
  [data-fs-bp-create-budget-drawer-header-arrow] {
33
38
  display: flex;
34
39
  flex-direction: row;
@@ -46,6 +51,10 @@
46
51
  }
47
52
  }
48
53
 
54
+ [data-fs-bp-create-budget-drawer-step-success="true"] {
55
+ border-bottom: none !important;
56
+ }
57
+
49
58
  [data-fs-bp-basic-drawer-button-variant="confirm"][disabled] {
50
59
  background-color: #0068d7;
51
60
  cursor: not-allowed;
@@ -1,5 +1,19 @@
1
1
  @import "../../../shared/components/BasicDrawer/basic-drawer.scss";
2
2
 
3
- [data-fs-bp-delete-user-drawer] {
3
+ [data-fs-bp-delete-allocation-drawer] {
4
4
  @import "../../../shared/components/InputText/input-text.scss";
5
+
6
+ &[data-fs-bp-basic-drawer] {
7
+ width: 100% !important;
8
+ max-width: none !important;
9
+
10
+ @include media(">=tablet") {
11
+ max-width: 30rem !important;
12
+ min-width: 30rem !important;
13
+ }
14
+
15
+ @include media(">=notebook") {
16
+ max-width: 40rem !important;
17
+ }
18
+ }
5
19
  }
@@ -7,8 +7,18 @@
7
7
  @import "../../../shared/components/ErrorMessage/error-message.scss";
8
8
 
9
9
  &[data-fs-bp-basic-drawer] {
10
- max-width: 60rem !important;
11
10
  width: 100% !important;
11
+ max-width: none !important;
12
+
13
+ @include media(">=tablet") {
14
+ max-width: 30rem !important;
15
+ min-width: 30rem !important;
16
+ }
17
+
18
+ @include media(">=notebook") {
19
+ max-width: 40rem !important;
20
+ }
21
+
12
22
  & > [data-fs-bp-basic-drawer-footer] {
13
23
  justify-content: flex-end !important;
14
24
  gap: var(--fs-spacing-1);