@vtex/faststore-plugin-buyer-portal 1.1.95 → 1.1.97

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 (58) hide show
  1. package/package.json +1 -1
  2. package/src/features/addresses/components/AddressLocationsList/AddressLocationsList.tsx +28 -39
  3. package/src/features/addresses/components/AddressRecipientsList/AddressRecipientsList.tsx +42 -42
  4. package/src/features/addresses/layouts/AddressDetailsLayout/address-details-layout.scss +285 -286
  5. package/src/features/addresses/layouts/AddressesLayout/AddressesLayout.tsx +26 -29
  6. package/src/features/addresses/layouts/AddressesLayout/addresses-layout.scss +144 -151
  7. package/src/features/budgets/components/BudgetAllocationsSelection/BudgetAllocationsSelection.tsx +61 -57
  8. package/src/features/budgets/components/BudgetAllocationsSelection/budget-allocations-selection.scss +131 -232
  9. package/src/features/budgets/components/BudgetAllocationsTable/BudgetAllocationsTable.tsx +104 -91
  10. package/src/features/budgets/components/BudgetAllocationsTable/budget-allocations-table.scss +80 -182
  11. package/src/features/budgets/components/BudgetsTable/BudgetsTable.tsx +90 -107
  12. package/src/features/budgets/components/BudgetsTable/budgets-table.scss +128 -126
  13. package/src/features/budgets/layouts/BudgetsLayout/BudgetsLayout.tsx +0 -15
  14. package/src/features/buying-policies/components/AddBuyingPolicyDrawer/AddBuyingPolicyDrawer.tsx +4 -0
  15. package/src/features/buying-policies/components/BasicBuyingPolicyDrawer/BasicBuyingPolicyDrawer.tsx +35 -4
  16. package/src/features/buying-policies/components/BasicBuyingPolicyDrawer/basic-buying-policy-drawer.scss +2 -1
  17. package/src/features/buying-policies/components/BudgetCriteriaSelector/BudgetCriteriaSelector.tsx +113 -0
  18. package/src/features/buying-policies/components/BudgetCriteriaSelector/budget-criteria-selector.scss +139 -0
  19. package/src/features/buying-policies/components/BudgetCriteriaSelector/index.ts +4 -0
  20. package/src/features/buying-policies/components/BuyingPolicyDropdownMenu/BuyingPolicyDropdownMenu.tsx +5 -0
  21. package/src/features/buying-policies/components/UpdateBuyingPolicyDrawer/UpdateBuyingPolicyDrawer.tsx +5 -0
  22. package/src/features/buying-policies/layouts/BuyingPoliciesLayout/BuyingPoliciesLayout.tsx +66 -46
  23. package/src/features/buying-policies/layouts/BuyingPoliciesLayout/buying-policies-layout.scss +64 -70
  24. package/src/features/buying-policies/utils/index.ts +4 -1
  25. package/src/features/buying-policies/utils/orderFieldsCriteriaOptions.ts +12 -9
  26. package/src/features/collections/components/CollectionsTable/CollectionsTable.tsx +12 -18
  27. package/src/features/collections/components/CollectionsTable/collections-table.scss +138 -118
  28. package/src/features/collections/components/table/AddCollectionsDrawerTable.tsx +48 -54
  29. package/src/features/collections/components/table/add-collections-drawer-table.scss +57 -56
  30. package/src/features/credit-cards/layouts/CreditCardsLayout/CreditCardLayout.tsx +55 -61
  31. package/src/features/credit-cards/layouts/CreditCardsLayout/credit-card-layout.scss +63 -153
  32. package/src/features/payment-methods/components/AddPaymentMethodsDrawer/AddPaymentMethodsDrawer.tsx +58 -49
  33. package/src/features/payment-methods/components/AddPaymentMethodsDrawer/add-payment-methods-drawer.scss +58 -63
  34. package/src/features/payment-methods/layouts/PaymentMethodsLayout/PaymentMethodsLayout.tsx +15 -12
  35. package/src/features/roles/layout/RoleDetailsLayout/RoleDetailsLayout.tsx +57 -26
  36. package/src/features/roles/layout/RoleDetailsLayout/role-details-layout.scss +77 -0
  37. package/src/features/roles/layout/RolesLayout/RolesLayout.tsx +4 -12
  38. package/src/features/roles/layout/RolesLayout/roles-layout.scss +8 -22
  39. package/src/features/shared/components/CustomField/table/CustomFieldTable.tsx +67 -110
  40. package/src/features/shared/components/CustomField/table/custom-field-table.scss +39 -144
  41. package/src/features/shared/components/IconBookmarked/IconBookmarked.tsx +9 -0
  42. package/src/features/shared/components/IconBookmarked/icon-bookmarked.scss +9 -0
  43. package/src/features/shared/components/Table/Table.tsx +7 -2
  44. package/src/features/shared/components/Table/TableCell/TableCell.tsx +15 -3
  45. package/src/features/shared/components/Table/TableCell/table-cell.scss +34 -0
  46. package/src/features/shared/components/Table/TableHead/TableHead.tsx +34 -6
  47. package/src/features/shared/components/Table/TableHead/table-head.scss +53 -49
  48. package/src/features/shared/components/Table/TableLoading/TableLoading.tsx +16 -6
  49. package/src/features/shared/components/Table/TableLoading/table-loading.scss +13 -8
  50. package/src/features/shared/components/Table/TableRow/TableRow.tsx +65 -42
  51. package/src/features/shared/components/Table/TableRow/table-row.scss +104 -68
  52. package/src/features/shared/components/Table/table.scss +11 -6
  53. package/src/features/shared/components/Table/utils/tableColumns.ts +30 -33
  54. package/src/features/shared/components/index.ts +1 -0
  55. package/src/features/users/layouts/UsersLayout/UsersLayout.tsx +20 -27
  56. package/src/pages/budgets.tsx +1 -1
  57. package/src/pages/buying-policies.tsx +14 -1
  58. package/src/themes/layouts.scss +1 -0
@@ -2,186 +2,84 @@
2
2
  @import "@faststore/ui/src/components/molecules/Tooltip/styles.scss";
3
3
 
4
4
  [data-fs-bp-budget-details-allocation-table] {
5
- @import "@faststore/ui/src/components/molecules/Table/styles.scss";
6
- @import "@faststore/ui/src/components/atoms/Skeleton/styles.scss";
7
- @import "@faststore/ui/src/components/atoms/Button/styles.scss";
8
- @import "@faststore/ui/src/components/molecules/Tooltip/styles.scss";
9
- @import "../../../shared/components/InternalSearch/internal-search.scss";
10
- @import "../../../shared/components/Tag/tag.scss";
11
- @import "../../../budgets/components/DeleteBudgetAllocationDrawer/delete-budget-allocations.scss";
12
- [data-fs-table] {
13
- overflow-x: visible;
14
- }
15
-
16
- [data-fs-budget-details-allocation-table-edit-line] {
17
- padding: calc(var(--fs-spacing-4) - var(--fs-spacing-0)) 0;
18
- border-top: var(--fs-border-width) solid #e0e0e0;
19
- display: flex;
20
- align-items: center;
21
-
22
- &:first-of-type {
23
- border-top: none;
24
- }
25
-
26
- [data-fs-budget-details-allocation-table-edit-title] {
27
- font-weight: var(--fs-text-weight-semibold);
28
- font-size: var(--fs-text-size-2);
29
- line-height: var(--fs-spacing-4);
30
- margin-right: auto;
31
- }
32
-
33
- [data-fs-budget-details-allocation-table-edit-button] {
34
- border: var(--fs-border-width) solid #e0e0e0;
35
- border-radius: var(--fs-border-radius-pill);
36
- padding: var(--fs-spacing-1)
37
- calc(var(--fs-spacing-4) - var(--fs-spacing-0));
38
- font-weight: var(--fs-text-weight-semibold);
39
- font-size: var(--fs-text-size-1);
40
- line-height: calc(var(--fs-spacing-4) - var(--fs-spacing-0));
41
- text-align: center;
42
- color: #0366dd;
43
- cursor: pointer;
44
- }
45
- }
46
-
47
- [data-fs-bp-budget-allocation-table-row-name] {
48
- width: fit-content;
49
- display: flex;
50
- flex-direction: row;
51
- align-items: center;
52
- gap: var(--fs-spacing-3);
53
- }
54
-
55
- [data-fs-bp-budget-allocation-table-row-name-td] {
56
- width: 14rem;
57
- }
58
-
59
- [data-fs-bp-budget-allocation-wrapper] {
60
- display: flex;
61
- flex-direction: row;
62
- margin-bottom: var(--fs-spacing-4);
63
- align-items: baseline;
64
- gap: var(--fs-spacing-1);
65
- }
66
-
67
- [data-fs-buyer-portal-budget-allocation-filter] {
68
- display: flex;
69
- gap: var(--fs-spacing-1);
70
- margin-bottom: var(--fs-spacing-4);
71
- justify-content: space-between;
72
- align-items: center;
73
-
74
- @include media("<tablet") {
75
- [data-fs-buyer-portal-internal-search] {
76
- width: 100%;
77
- }
78
- }
79
- }
80
-
81
- [data-fs-bp-pagination-span] {
82
- color: #707070;
83
- font-weight: var(--fs-text-weight-medium);
84
- font-size: var(--fs-text-size-1);
85
- line-height: calc(var(--fs-spacing-3) + var(--fs-spacing-0));
86
- }
87
-
88
- [data-fs-table-head="true"] {
89
- [data-fs-table-row="true"] {
90
- [data-fs-table-cell="header"] {
91
- height: var(--fs-spacing-6);
92
- padding: 0;
93
-
94
- font-weight: var(--fs-text-weight-regular);
95
- color: #5c5c5c;
96
- font-size: var(--fs-text-size-1);
97
- }
98
- }
99
- }
100
-
101
- [data-fs-table-body="true"] {
102
- [data-fs-table-row="true"] {
103
- &:first-child {
104
- border-top: var(--fs-border-width) solid #d6d6d6;
105
- }
106
- &:last-child {
107
- border-bottom: none;
108
- }
109
-
110
- &:hover {
111
- background-color: #f5f5f5;
112
- }
113
- [data-fs-table-cell] {
114
- height: var(--fs-spacing-8);
115
- font-weight: var(--fs-text-weight-medium);
116
- color: #1f1f1f;
117
- font-size: var(--fs-text-size-1);
118
- padding: 0;
119
-
120
- @include media("<tablet") {
121
- padding: 0 var(--fs-spacing-1);
122
- }
123
-
124
- [data-fs-icon] {
125
- display: inline-block;
126
-
127
- margin: 0;
128
- &[data-fs-bp-budget-allocation-table-trash-icon] {
129
- color: #000000;
130
- }
131
- &[data-fs-bp-budget-allocation-table-icon] {
132
- color: #0366dd;
133
- width: var(--fs-spacing-4);
134
- height: var(--fs-spacing-4);
135
- }
136
- }
137
-
138
- [data-fs-button] {
139
- width: var(--fs-spacing-7);
140
- height: var(--fs-spacing-7);
141
-
142
- [data-fs-button-wrapper] {
143
- border-radius: var(--fs-border-radius-pill);
144
- padding: 0;
145
- }
146
- }
147
-
148
- &:first-child {
149
- text-align: center;
150
- > svg {
151
- margin: 0;
152
- }
153
- }
154
- }
155
- }
156
- }
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
-
172
- [data-fs-skeleton] {
173
- display: inline-block;
174
- }
175
-
176
- [data-fs-empty-state-section] {
177
- padding: var(--fs-spacing-13);
178
- width: 32rem;
179
- text-align: center;
180
- margin: 0 auto;
181
-
182
- @include media("<tablet") {
183
- width: 100%;
184
- padding: var(--fs-spacing-4);
185
- }
186
- }
5
+ @import "@faststore/ui/src/components/atoms/Skeleton/styles.scss";
6
+ @import "@faststore/ui/src/components/atoms/Button/styles.scss";
7
+ @import "@faststore/ui/src/components/molecules/Tooltip/styles.scss";
8
+ @import "../../../shared/components/InternalSearch/internal-search.scss";
9
+ @import "../../../shared/components/Tag/tag.scss";
10
+ @import "../../../budgets/components/DeleteBudgetAllocationDrawer/delete-budget-allocations.scss";
11
+ @import "../../../shared/components/Table/table.scss";
12
+
13
+ [data-fs-budget-details-allocation-table-edit-line] {
14
+ padding: calc(var(--fs-spacing-4) - var(--fs-spacing-0)) 0;
15
+ border-top: var(--fs-border-width) solid #e0e0e0;
16
+ display: flex;
17
+ align-items: center;
18
+
19
+ &:first-of-type {
20
+ border-top: none;
21
+ }
22
+
23
+ [data-fs-budget-details-allocation-table-edit-title] {
24
+ font-weight: var(--fs-text-weight-semibold);
25
+ font-size: var(--fs-text-size-2);
26
+ line-height: var(--fs-spacing-4);
27
+ margin-right: auto;
28
+ }
29
+
30
+ [data-fs-budget-details-allocation-table-edit-button] {
31
+ border: var(--fs-border-width) solid #e0e0e0;
32
+ border-radius: var(--fs-border-radius-pill);
33
+ padding: var(--fs-spacing-1) calc(var(--fs-spacing-4) - var(--fs-spacing-0));
34
+ font-weight: var(--fs-text-weight-semibold);
35
+ font-size: var(--fs-text-size-1);
36
+ line-height: calc(var(--fs-spacing-4) - var(--fs-spacing-0));
37
+ text-align: center;
38
+ color: #0366dd;
39
+ cursor: pointer;
40
+ }
41
+ }
42
+
43
+ [data-fs-buyer-portal-budget-allocation-filter] {
44
+ display: flex;
45
+ gap: var(--fs-spacing-1);
46
+ margin-bottom: var(--fs-spacing-4);
47
+ justify-content: space-between;
48
+ align-items: center;
49
+
50
+ @include media("<tablet") {
51
+ [data-fs-buyer-portal-internal-search] {
52
+ width: 100%;
53
+ }
54
+ }
55
+ }
56
+
57
+ [data-fs-bp-pagination-span] {
58
+ color: #707070;
59
+ font-weight: var(--fs-text-weight-medium);
60
+ font-size: var(--fs-text-size-1);
61
+ line-height: calc(var(--fs-spacing-3) + var(--fs-spacing-0));
62
+ }
63
+
64
+ [data-fs-empty-state-section] {
65
+ padding: var(--fs-spacing-13);
66
+ width: 32rem;
67
+ text-align: center;
68
+ margin: 0 auto;
69
+
70
+ @include media("<tablet") {
71
+ width: 100%;
72
+ padding: var(--fs-spacing-4);
73
+ }
74
+ }
75
+
76
+ [data-fs-bp-budget-allocation-table-trash-icon] {
77
+ --fs-button-height: var(--fs-spacing-6);
78
+ --fs-button-border-radius: 50%;
79
+
80
+ [data-fs-button-icon] {
81
+ cursor: pointer;
82
+ color: #1f1f1f;
83
+ }
84
+ }
187
85
  }
@@ -1,19 +1,14 @@
1
- import {
2
- Dropdown,
3
- DropdownItem,
4
- Table,
5
- TableBody,
6
- TableCell,
7
- TableHead,
8
- TableRow,
9
- } from "@faststore/ui";
1
+ import { useRouter } from "next/router";
10
2
 
11
- import { Icon } from "../../../shared/components";
3
+ import { DropdownItem } from "@faststore/ui";
4
+
5
+ import { Icon, Table } from "../../../shared/components";
12
6
  import { BasicDropdownMenu } from "../../../shared/components/BasicDropdownMenu/BasicDropdownMenu";
13
- import { BasicDropdownMenuTrigger } from "../../../shared/components/BasicDropdownMenu/BasicDropdownMenuTrigger";
7
+ import { getTableColumns } from "../../../shared/components/Table/utils/tableColumns";
8
+ import { useBuyerPortal } from "../../../shared/hooks";
14
9
  import { formatCurrency } from "../../../shared/utils";
10
+ import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
15
11
  import { BudgetProgressBar } from "../BudgetProgressBar/BudgetProgressBar";
16
- import BudgetSkeleton from "../BudgetSkeleton/BudgetSkeleton";
17
12
 
18
13
  import type { BudgetList } from "../../types";
19
14
 
@@ -23,131 +18,119 @@ interface IBudgetsTable {
23
18
  openDeleteDrawer(budgetId: string): void;
24
19
  onClickAllocationPage(budgetId: string): void;
25
20
  onClickEditBudget(budgetId: string): void;
26
- onClickDetailsPage: (budgetId: string) => void;
27
21
  openDeleteDrawer(budgetId: string): void;
28
22
  loading: boolean;
29
23
  }
30
24
 
31
25
  export function BudgetsTable({
32
26
  data,
33
- onClickDetailsPage,
34
27
  onClickAllocationPage,
35
28
  onClickEditBudget,
36
29
  openDeleteDrawer,
37
30
  loading,
38
31
  }: IBudgetsTable) {
39
32
  const budgets = data;
33
+ const route = useRouter();
34
+ const { currentOrgUnit: orgUnit, currentContract: contract } =
35
+ useBuyerPortal();
36
+
37
+ const detailsRoute = (budgetId: string) =>
38
+ buyerPortalRoutes.budgetsDetails({
39
+ orgUnitId: orgUnit?.id ?? "",
40
+ contractId: contract?.id ?? "",
41
+ budgetId,
42
+ });
43
+
44
+ const columns = getTableColumns({
45
+ nameColumnSize: "18.625rem",
46
+ actionsLength: 1.75,
47
+ extraColumns: [
48
+ {
49
+ label: "Remaining",
50
+ key: "remaining",
51
+ size: "100%",
52
+ hideOnScreenSize: "phonemid",
53
+ align: "left",
54
+ },
55
+ {
56
+ label: "Expiration date",
57
+ key: "date",
58
+ size: "8.75rem",
59
+ hideOnScreenSize: "phonemid",
60
+ align: "right",
61
+ },
62
+ {
63
+ label: "Total (USD)",
64
+ key: "total",
65
+ size: "8.75rem",
66
+ hideOnScreenSize: "tablet",
67
+ align: "right",
68
+ },
69
+ ],
70
+ });
40
71
 
41
72
  return (
42
73
  <div data-fs-bp-budgets-table>
43
- <Table variant="bordered">
44
- <TableHead>
45
- <TableRow data-fs-bp-head-row data-fs-bp-text-regular>
46
- <TableCell scope="col" variant="data" align="left">
47
- Name
48
- </TableCell>
49
- <TableCell
50
- data-fs-table-cell-width
51
- data-fs-bp-cell-remaining
52
- scope="col"
53
- variant="data"
54
- align="left"
55
- >
56
- Remaining
57
- </TableCell>
58
- <TableCell scope="col" variant="data" align="center">
59
- Expiration date
60
- </TableCell>
61
- <TableCell
62
- scope="col"
63
- variant="data"
64
- align="center"
65
- data-fs-bp-cell-currency
66
- >
67
- Total (USD)
68
- </TableCell>
69
- <TableCell scope="col" variant="data" align="right" />
70
- </TableRow>
71
- </TableHead>
72
- <TableBody>
74
+ <Table layoutFixed>
75
+ <Table.Head columns={columns} />
76
+ <Table.Body>
73
77
  {loading ? (
74
- <BudgetSkeleton />
78
+ <Table.Loading columns={columns.length} />
75
79
  ) : (
76
80
  budgets.map((item) => (
77
- <TableRow
81
+ <Table.Row
78
82
  key={item.id}
79
- onClick={() => onClickDetailsPage(item.id)}
83
+ title={item.name}
84
+ iconName="Paid"
85
+ iconSize={24}
86
+ href={detailsRoute(item.id)}
87
+ dropdownMenu={
88
+ <BasicDropdownMenu>
89
+ <DropdownItem
90
+ onClick={() => route.push(detailsRoute(item.id))}
91
+ >
92
+ <Icon name="OpenInNew" width={20} height={20} />
93
+ <span>Open</span>
94
+ </DropdownItem>
95
+ <DropdownItem onClick={() => onClickEditBudget(item.id)}>
96
+ <Icon name="Edit" width={20} height={20} />
97
+ <span>Edit settings</span>
98
+ </DropdownItem>
99
+ <DropdownItem
100
+ onClick={() => onClickAllocationPage(item.id)}
101
+ >
102
+ <Icon name="Add" width={20} height={20} />
103
+ <span>Add allocations</span>
104
+ </DropdownItem>
105
+ <BasicDropdownMenu.Separator />
106
+ <DropdownItem
107
+ data-fs-bp-dropdown-menu-item-mode="danger"
108
+ onClick={() => openDeleteDrawer(item.id)}
109
+ >
110
+ <Icon name="Delete" width={20} height={20} />
111
+ <span>Delete</span>
112
+ </DropdownItem>
113
+ </BasicDropdownMenu>
114
+ }
80
115
  >
81
- <TableCell
82
- align="left"
83
- data-fs-bp-icon-cell
84
- data-fs-bp-text-medium
85
- >
86
- <Icon color="#0366DD" name="Paid" />
87
- {item.name}
88
- </TableCell>
89
- <TableCell
90
- align="left"
91
- data-fs-bp-text-medium
92
- data-fs-table-cell-width
93
- >
116
+ <Table.Cell hideOnScreenSize="phonemid" align="left">
94
117
  <BudgetProgressBar
95
118
  remaining={item.remaining}
96
119
  total={item.total}
97
120
  />
98
- </TableCell>
99
- <TableCell align="center" data-fs-bp-text-medium>
121
+ </Table.Cell>
122
+ <Table.Cell hideOnScreenSize="phonemid" align="right">
100
123
  {new Intl.DateTimeFormat("pt-BR").format(
101
124
  new Date(item.expirationDate)
102
125
  )}
103
- </TableCell>
104
- <TableCell
105
- align="center"
106
- data-fs-bp-text-medium
107
- data-fs-bp-cell-currency
108
- >
126
+ </Table.Cell>
127
+ <Table.Cell hideOnScreenSize="tablet" align="right">
109
128
  {formatCurrency(item.total)}
110
- </TableCell>
111
- <TableCell
112
- data-fs-bp-table-row-options
113
- align="right"
114
- onClick={(e) => e.stopPropagation()}
115
- >
116
- <Dropdown>
117
- <BasicDropdownMenuTrigger
118
- data-fs-bp-budgets-dropdown-trigger
119
- iconName="MoreVert"
120
- />
121
- <BasicDropdownMenu>
122
- <DropdownItem onClick={() => onClickDetailsPage(item.id)}>
123
- <Icon name="OpenInNew" width={20} height={20} />
124
- <span>Open</span>
125
- </DropdownItem>
126
- <DropdownItem onClick={() => onClickEditBudget(item.id)}>
127
- <Icon name="Edit" width={20} height={20} />
128
- <span>Edit settings</span>
129
- </DropdownItem>
130
- <DropdownItem
131
- onClick={() => onClickAllocationPage(item.id)}
132
- >
133
- <Icon name="Add" width={20} height={20} />
134
- <span>Add allocations</span>
135
- </DropdownItem>
136
- <BasicDropdownMenu.Separator />
137
- <DropdownItem
138
- data-fs-bp-dropdown-menu-item-mode="danger"
139
- onClick={() => openDeleteDrawer(item.id)}
140
- >
141
- <Icon name="Delete" width={20} height={20} />
142
- <span>Delete</span>
143
- </DropdownItem>
144
- </BasicDropdownMenu>
145
- </Dropdown>
146
- </TableCell>
147
- </TableRow>
129
+ </Table.Cell>
130
+ </Table.Row>
148
131
  ))
149
132
  )}
150
- </TableBody>
133
+ </Table.Body>
151
134
  </Table>
152
135
  </div>
153
136
  );