@vtex/faststore-plugin-buyer-portal 1.3.17 → 1.3.18
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 +17 -6
- package/package.json +1 -1
- package/src/features/budgets/components/BudgetDeleteDrawer/BudgetDeleteDrawer.tsx +1 -1
- package/src/features/budgets/components/BudgetEditNotificationDrawer/BudgetEditNotificationDrawer.tsx +139 -0
- package/src/features/budgets/components/BudgetEditNotificationDrawer/budget-edit-notification-drawer.scss +34 -0
- package/src/features/budgets/components/BudgetNotificationForm/BudgetNotificationForm.tsx +361 -0
- package/src/features/budgets/components/BudgetNotificationForm/budget-notification-form.scss +219 -0
- package/src/features/budgets/components/BudgetNotificationsInfo/BudgetNotificationsInfo.tsx +116 -0
- package/src/features/budgets/components/BudgetNotificationsInfo/budget-notifications-info.scss +97 -0
- package/src/features/budgets/components/BudgetUsersTable/BudgetUsersTable.tsx +118 -0
- package/src/features/budgets/components/BudgetUsersTable/budget-users-table.scss +65 -0
- package/src/features/budgets/components/BudgetsTable/BudgetsTable.tsx +10 -0
- package/src/features/budgets/components/CreateBudgetAllocationDrawer/CreateBudgetAllocationDrawer.tsx +1 -1
- package/src/features/budgets/components/CreateBudgetDrawer/CreateBudgetDrawer.tsx +86 -25
- package/src/features/budgets/components/CreateBudgetDrawer/create-budget-drawer.scss +6 -0
- package/src/features/budgets/components/DeleteBudgetAllocationDrawer/DeleteBudgetAllocationDrawer.tsx +1 -1
- package/src/features/budgets/components/EditBudgetDrawer/EditBudgetDrawer.tsx +40 -1
- package/src/features/budgets/components/EditBudgetDrawer/edit-budget-drawer.scss +5 -0
- package/src/features/budgets/hooks/useDebouncedSearchBudgetNotification.ts +37 -0
- package/src/features/budgets/hooks/useListUsers.ts +1 -1
- package/src/features/budgets/layouts/BudgetsDetailsLayout/BudgetsDetailsLayout.tsx +9 -1
- package/src/features/budgets/layouts/BudgetsDetailsLayout/budget-details-layout.scss +14 -1
- package/src/features/budgets/layouts/BudgetsLayout/BudgetsLayout.tsx +39 -0
- package/src/features/budgets/layouts/BudgetsLayout/budgets-layout.scss +1 -1
- package/src/features/budgets/types/index.ts +17 -0
- package/src/features/shared/components/AutocompleteDropdown/AutocompleteDropdownItem.tsx +4 -0
- package/src/features/shared/components/QuantitySelectorWithPercentage/QuantitySelectorWithPercentage.tsx +150 -0
- package/src/features/shared/components/index.ts +24 -23
- package/src/features/shared/types/CurrencyType.d.ts +4 -0
- package/src/features/shared/types/index.ts +4 -3
- package/src/features/shared/utils/budgetAmountParse.ts +24 -0
- package/src/features/shared/utils/constants.ts +1 -1
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
[data-fs-bp-budget-notification] {
|
|
2
|
+
@import "@faststore/ui/src/components/molecules/Toggle/styles.scss";
|
|
3
|
+
@import "@faststore/ui/src/components/molecules/Tooltip/styles.scss";
|
|
4
|
+
@import "@faststore/ui/src/components/molecules/QuantitySelector/styles.scss";
|
|
5
|
+
@import "../../../shared/components/InputText/input-text.scss";
|
|
6
|
+
@import "../../../shared/components/Table/table.scss";
|
|
7
|
+
@import "../../../shared/components/ErrorMessage/error-message.scss";
|
|
8
|
+
@import "../BudgetUsersTable/budget-users-table.scss";
|
|
9
|
+
|
|
10
|
+
padding-bottom: var(--fs-spacing-7);
|
|
11
|
+
|
|
12
|
+
[data-fs-bp-budget-notification-section-user] {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
gap: var(--fs-spacing-3);
|
|
16
|
+
margin-top: var(--fs-spacing-5);
|
|
17
|
+
|
|
18
|
+
[data-fs-bp-budget-notification-autocomplete] {
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
gap: var(--fs-spacing-1);
|
|
22
|
+
span:first-child {
|
|
23
|
+
font-weight: var(--fs-text-weight-semibold);
|
|
24
|
+
color: #000000;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
[data-fs-bp-budget-notification-section-label] {
|
|
30
|
+
font-weight: var(--fs-text-weight-regular);
|
|
31
|
+
font-size: var(--fs-text-size-1);
|
|
32
|
+
color: #5c5c5c;
|
|
33
|
+
line-height: calc(var(--fs-spacing-3) + var(--fs-spacing-0));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
[data-fs-bp-budget-notification-row-section] {
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
width: 100%;
|
|
40
|
+
|
|
41
|
+
@include media(">=notebook") {
|
|
42
|
+
align-items: center;
|
|
43
|
+
flex-direction: row;
|
|
44
|
+
gap: var(--fs-spacing-3);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&[data-fs-bp-budget-notification-renew] {
|
|
48
|
+
justify-content: space-between;
|
|
49
|
+
flex-direction: row;
|
|
50
|
+
|
|
51
|
+
[data-fs-bp-budget-notification-renew-label] {
|
|
52
|
+
font-weight: var(--fs-text-weight-semibold);
|
|
53
|
+
font-size: var(--fs-text-size-2);
|
|
54
|
+
color: #000000;
|
|
55
|
+
margin-bottom: var(--fs-spacing-1);
|
|
56
|
+
}
|
|
57
|
+
[data-fs-toggle] {
|
|
58
|
+
width: var(--fs-spacing-6);
|
|
59
|
+
height: var(--fs-spacing-4);
|
|
60
|
+
min-width: auto;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
[data-fs-bp-autocomplete-dropdown]{
|
|
66
|
+
[data-fs-bp-autocomplete-dropdown-menu]{
|
|
67
|
+
z-index:2;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
[data-fs-bp-budget-notification-data-section] {
|
|
72
|
+
& > div {
|
|
73
|
+
flex: 1;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
[data-fs-bp-basic-drawer-footer] {
|
|
78
|
+
justify-content: flex-end;
|
|
79
|
+
gap: var(--fs-spacing-1);
|
|
80
|
+
}
|
|
81
|
+
[data-fs-bp-budget-notification-row-section-action] {
|
|
82
|
+
display: flex;
|
|
83
|
+
flex-direction: row;
|
|
84
|
+
gap: var(--fs-spacing-3);
|
|
85
|
+
align-items: center;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
[data-fs-bp-budget-notification-table] {
|
|
89
|
+
margin-top: var(--fs-spacing-3);
|
|
90
|
+
width: 100%;
|
|
91
|
+
display: block;
|
|
92
|
+
|
|
93
|
+
[data-fs-bp-table] {
|
|
94
|
+
[data-fs-bp-table-head] {
|
|
95
|
+
[data-fs-bp-table-head-row] {
|
|
96
|
+
border-bottom: var(--fs-border-radius-small) solid #e0e0e0;
|
|
97
|
+
|
|
98
|
+
th[data-fs-bp-table-head-column] {
|
|
99
|
+
text-align: start;
|
|
100
|
+
font-weight: var(--fs-text-weight-medium);
|
|
101
|
+
font-size: var(--fs-text-size-1);
|
|
102
|
+
color: #5c5c5c;
|
|
103
|
+
padding: var(--fs-spacing-2) 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
th[data-fs-bp-table-head-column]:last-child {
|
|
107
|
+
min-width: var(--fs-spacing-4);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
[data-fs-bp-budget-notification-stepper] {
|
|
114
|
+
display: inline-flex;
|
|
115
|
+
align-items: center;
|
|
116
|
+
gap: var(--fs-spacing-1);
|
|
117
|
+
|
|
118
|
+
&[data-fs-bp-budget-notification-stepper-qty-wrapper] {
|
|
119
|
+
position: relative;
|
|
120
|
+
display: inline-block;
|
|
121
|
+
|
|
122
|
+
[data-fs-bp-budget-notification-stepper-qty-suffix] {
|
|
123
|
+
position: absolute;
|
|
124
|
+
right: var(--fs-spacing-2);
|
|
125
|
+
top: 50%;
|
|
126
|
+
transform: translateY(-50%);
|
|
127
|
+
pointer-events: none;
|
|
128
|
+
opacity: 0.7;
|
|
129
|
+
font: inherit;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
div[data-fs-quantity-selector] {
|
|
134
|
+
height: 2.25rem;
|
|
135
|
+
width: 7.75rem;
|
|
136
|
+
border-radius: var(--fs-border-radius-pill);
|
|
137
|
+
border: var(--fs-border-radius-small) solid #d6d6d6;
|
|
138
|
+
--fs-qty-selector-border-radius: var(--fs-border-radius-pill);
|
|
139
|
+
|
|
140
|
+
[data-fs-input] {
|
|
141
|
+
height: 2.25rem;
|
|
142
|
+
color: #000000;
|
|
143
|
+
font-weight: var(--fs-text-weight-regular);
|
|
144
|
+
font-size: var(--fs-text-size-1);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
button {
|
|
148
|
+
cursor: pointer;
|
|
149
|
+
&:first-child {
|
|
150
|
+
left: 0.3125rem;
|
|
151
|
+
}
|
|
152
|
+
&:last-child {
|
|
153
|
+
right: 0.3125rem;
|
|
154
|
+
}
|
|
155
|
+
border: none;
|
|
156
|
+
[data-fs-button-wrapper] {
|
|
157
|
+
[data-fs-button-icon] {
|
|
158
|
+
svg {
|
|
159
|
+
color: #0068d7;
|
|
160
|
+
width: 1.25rem;
|
|
161
|
+
height: 1.25rem;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
div[data-fs-quantity-selector="disabled"] {
|
|
169
|
+
[data-fs-input] {
|
|
170
|
+
color: #c3c3c3;
|
|
171
|
+
}
|
|
172
|
+
--fs-qty-selector-bkg-color: #ebeaea;
|
|
173
|
+
button {
|
|
174
|
+
[data-fs-button-wrapper] {
|
|
175
|
+
[data-fs-button-icon] {
|
|
176
|
+
svg {
|
|
177
|
+
color: #c3c3c3;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
[data-fs-bp-budget-notification-money] {
|
|
186
|
+
font-weight: var(--fs-text-weight-regular);
|
|
187
|
+
font-size: var(--fs-text-size-1);
|
|
188
|
+
color: #5C5C5C;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
[data-fs-bp-budget-notification-remove] {
|
|
192
|
+
color: #000000;
|
|
193
|
+
stroke-width: 1.3rem;
|
|
194
|
+
&[disabled] {
|
|
195
|
+
color: #9ca3af; /* gray when disabled */
|
|
196
|
+
cursor: not-allowed;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
[data-fs-bp-budget-notification-add] {
|
|
201
|
+
margin-top: var(--fs-spacing-3);
|
|
202
|
+
display: flex;
|
|
203
|
+
align-items: center;
|
|
204
|
+
gap: var(--fs-spacing-2);
|
|
205
|
+
|
|
206
|
+
button {
|
|
207
|
+
height: var(--fs-spacing-6);
|
|
208
|
+
width: 8.4375rem;
|
|
209
|
+
border-radius: var(--fs-border-radius-pill);
|
|
210
|
+
border: var(--fs-border-radius-small) solid #d6d6d6;
|
|
211
|
+
|
|
212
|
+
background: #fff;
|
|
213
|
+
padding: 0 var(--fs-spacing-3);
|
|
214
|
+
color: #0068d7;
|
|
215
|
+
font-size: var(--fs-text-size-1);
|
|
216
|
+
font-weight: var(--fs-text-weight-semibold);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Badge } from "@faststore/ui";
|
|
2
|
+
|
|
3
|
+
import { EmptyState } from "../../../shared/components";
|
|
4
|
+
import { useDrawerProps } from "../../../shared/hooks";
|
|
5
|
+
import { BudgetEditNotificationDrawer } from "../BudgetEditNotificationDrawer/BudgetEditNotificationDrawer";
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
Budget,
|
|
9
|
+
BudgetNotification,
|
|
10
|
+
NotificationThresholds,
|
|
11
|
+
NotificationUsers,
|
|
12
|
+
} from "../../types";
|
|
13
|
+
|
|
14
|
+
type BudgetNotificationsInfoProps = {
|
|
15
|
+
initialBudget: Budget;
|
|
16
|
+
contractId: string;
|
|
17
|
+
orgUnitId: string;
|
|
18
|
+
budgetId: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const DetailRow = ({
|
|
22
|
+
label,
|
|
23
|
+
notifications,
|
|
24
|
+
}: {
|
|
25
|
+
label: string;
|
|
26
|
+
notifications: BudgetNotification;
|
|
27
|
+
}) => {
|
|
28
|
+
const isUserLabel = label === "Users";
|
|
29
|
+
const list = isUserLabel
|
|
30
|
+
? (notifications.users as NotificationUsers[])
|
|
31
|
+
: (notifications.thresholds as NotificationThresholds[]);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
<div data-fs-bp-budget-notifications-details-row>
|
|
36
|
+
<span data-fs-bp-budget-notifications-details-row-label>{label}</span>
|
|
37
|
+
<span data-fs-bp-budget-notifications-details-row-value>
|
|
38
|
+
{list.map((item, index) => (
|
|
39
|
+
<Badge key={index} size="big">
|
|
40
|
+
{isUserLabel
|
|
41
|
+
? (item as NotificationUsers).userName
|
|
42
|
+
: `${(item as NotificationThresholds).value}%`}
|
|
43
|
+
</Badge>
|
|
44
|
+
))}
|
|
45
|
+
</span>
|
|
46
|
+
</div>
|
|
47
|
+
<hr data-fs-bp-budget-notifications-divider />
|
|
48
|
+
</>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const BudgetNotificationsInfo = ({
|
|
53
|
+
initialBudget,
|
|
54
|
+
budgetId,
|
|
55
|
+
orgUnitId,
|
|
56
|
+
contractId,
|
|
57
|
+
}: BudgetNotificationsInfoProps) => {
|
|
58
|
+
const {
|
|
59
|
+
open: openNotificationsDrawerProps,
|
|
60
|
+
isOpen: isEditDrawerOpen,
|
|
61
|
+
...editDrawerProps
|
|
62
|
+
} = useDrawerProps();
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<>
|
|
66
|
+
<div data-fs-bp-budget-notifications>
|
|
67
|
+
<div data-fs-bp-budget-notifications-details>
|
|
68
|
+
<div data-fs-budget-notifications-edit-line>
|
|
69
|
+
<span data-fs-budget-notifications-edit-title>Notifications</span>
|
|
70
|
+
<button
|
|
71
|
+
type="button"
|
|
72
|
+
data-fs-budget-notifications-edit-button
|
|
73
|
+
onClick={openNotificationsDrawerProps}
|
|
74
|
+
>
|
|
75
|
+
Edit
|
|
76
|
+
</button>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
{initialBudget.notifications?.hasNotification ? (
|
|
80
|
+
<>
|
|
81
|
+
<hr data-fs-bp-budget-notifications-divider />
|
|
82
|
+
<DetailRow
|
|
83
|
+
key="Thresholds"
|
|
84
|
+
label="Thresholds"
|
|
85
|
+
notifications={initialBudget.notifications}
|
|
86
|
+
/>
|
|
87
|
+
<DetailRow
|
|
88
|
+
key="Users"
|
|
89
|
+
label="Users"
|
|
90
|
+
notifications={initialBudget.notifications}
|
|
91
|
+
/>
|
|
92
|
+
</>
|
|
93
|
+
) : (
|
|
94
|
+
<div data-fs-bp-budget-notifications-empty>
|
|
95
|
+
<EmptyState
|
|
96
|
+
title="No notifications"
|
|
97
|
+
description="Set up to 5 thresholds and notify users when the total amount reaches specific percentages."
|
|
98
|
+
/>
|
|
99
|
+
</div>
|
|
100
|
+
)}
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
{isEditDrawerOpen && (
|
|
105
|
+
<BudgetEditNotificationDrawer
|
|
106
|
+
{...editDrawerProps}
|
|
107
|
+
isOpen={isEditDrawerOpen}
|
|
108
|
+
budget={initialBudget}
|
|
109
|
+
contractId={contractId}
|
|
110
|
+
orgUnitId={orgUnitId}
|
|
111
|
+
budgetId={budgetId}
|
|
112
|
+
/>
|
|
113
|
+
)}
|
|
114
|
+
</>
|
|
115
|
+
);
|
|
116
|
+
};
|
package/src/features/budgets/components/BudgetNotificationsInfo/budget-notifications-info.scss
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
[data-fs-bp-budget-notifications] {
|
|
2
|
+
@import "@faststore/ui/src/components/atoms/Badge/styles.scss";
|
|
3
|
+
|
|
4
|
+
width: 100%;
|
|
5
|
+
|
|
6
|
+
[data-fs-bp-budget-notifications-details-title] {
|
|
7
|
+
font-weight: var(--fs-text-weight-semibold);
|
|
8
|
+
font-size: var(--fs-text-size-2);
|
|
9
|
+
display: flex;
|
|
10
|
+
justify-content: space-between;
|
|
11
|
+
align-items: center;
|
|
12
|
+
padding: var(--fs-spacing-3) 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
[data-fs-bp-budget-notifications-divider] {
|
|
16
|
+
border: calc(var(--fs-border-width) / 2) solid #e0e0e0;
|
|
17
|
+
|
|
18
|
+
&:first-of-type {
|
|
19
|
+
@include media("<tablet") {
|
|
20
|
+
border: none;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[data-fs-bp-budget-notifications-details-row] {
|
|
26
|
+
display: flex;
|
|
27
|
+
padding: 1.375rem 0;
|
|
28
|
+
font-weight: var(--fs-text-weight-medium);
|
|
29
|
+
font-size: var(--fs-text-size-1);
|
|
30
|
+
line-height: calc(var(--fs-spacing-3) + var(--fs-spacing-0));
|
|
31
|
+
|
|
32
|
+
@include media("<tablet") {
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
padding: var(--fs-spacing-2) 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
[data-fs-bp-budget-notifications-details-row-label] {
|
|
38
|
+
width: 12.5rem;
|
|
39
|
+
color: #707070;
|
|
40
|
+
font-size: var(--fs-text-size-1);
|
|
41
|
+
font-weight: var(--fs-text-weight-regular);
|
|
42
|
+
|
|
43
|
+
@include media("<tablet") {
|
|
44
|
+
font-size: var(--fs-text-size-0);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
[data-fs-bp-budget-notifications-details-row-value] {
|
|
49
|
+
color: #000000;
|
|
50
|
+
font-size: var(--fs-text-size-1);
|
|
51
|
+
font-weight: var(--fs-text-weight-medium);
|
|
52
|
+
display: flex;
|
|
53
|
+
gap: var(--fs-spacing-1);
|
|
54
|
+
|
|
55
|
+
[data-fs-badge] {
|
|
56
|
+
color: #000000;
|
|
57
|
+
font-size: var(--fs-text-size-0);
|
|
58
|
+
font-weight: var(--fs-text-weight-regular);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@include media("<tablet") {
|
|
62
|
+
font-weight: var(--fs-text-weight-regular);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
[data-fs-budget-notifications-edit-line] {
|
|
68
|
+
padding: calc(var(--fs-spacing-4) - var(--fs-spacing-0)) 0;
|
|
69
|
+
border-top: var(--fs-border-width) solid #e0e0e0;
|
|
70
|
+
display: flex;
|
|
71
|
+
align-items: center;
|
|
72
|
+
|
|
73
|
+
&:first-of-type {
|
|
74
|
+
border-top: none;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
[data-fs-budget-notifications-edit-title] {
|
|
78
|
+
font-weight: var(--fs-text-weight-semibold);
|
|
79
|
+
font-size: var(--fs-text-size-2);
|
|
80
|
+
line-height: var(--fs-spacing-4);
|
|
81
|
+
margin-right: auto;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
[data-fs-budget-notifications-edit-button] {
|
|
85
|
+
border: var(--fs-border-width) solid #e0e0e0;
|
|
86
|
+
border-radius: var(--fs-border-radius-pill);
|
|
87
|
+
padding: var(--fs-spacing-1)
|
|
88
|
+
calc(var(--fs-spacing-4) - var(--fs-spacing-0));
|
|
89
|
+
font-weight: var(--fs-text-weight-semibold);
|
|
90
|
+
font-size: var(--fs-text-size-1);
|
|
91
|
+
line-height: calc(var(--fs-spacing-4) - var(--fs-spacing-0));
|
|
92
|
+
text-align: center;
|
|
93
|
+
color: #0366dd;
|
|
94
|
+
cursor: pointer;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { memo } from "react";
|
|
2
|
+
|
|
3
|
+
import { Icon, Tooltip } from "@faststore/ui";
|
|
4
|
+
|
|
5
|
+
import { Table } from "../../../shared/components";
|
|
6
|
+
import { getTableColumns } from "../../../shared/components/Table/utils/tableColumns";
|
|
7
|
+
import { useBuyerPortal } from "../../../shared/hooks";
|
|
8
|
+
|
|
9
|
+
type UserRow = {
|
|
10
|
+
userId: string;
|
|
11
|
+
userName: string;
|
|
12
|
+
email: string;
|
|
13
|
+
removable?: boolean;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type BudgetUsersTableProps = {
|
|
17
|
+
users: UserRow[];
|
|
18
|
+
onRemove?: (userId: string) => void;
|
|
19
|
+
emptyMessage?: string;
|
|
20
|
+
className?: string;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function BudgetUsersTableBase({
|
|
25
|
+
users,
|
|
26
|
+
onRemove,
|
|
27
|
+
emptyMessage = "No users found",
|
|
28
|
+
className,
|
|
29
|
+
disabled = false,
|
|
30
|
+
}: BudgetUsersTableProps) {
|
|
31
|
+
const { clientContext } = useBuyerPortal();
|
|
32
|
+
const currClientId = clientContext.userId;
|
|
33
|
+
const columns = getTableColumns({
|
|
34
|
+
actionsLength: onRemove ? 1 : 0,
|
|
35
|
+
nameColumnLabel: "User name",
|
|
36
|
+
nameColumnKey: "name",
|
|
37
|
+
nameColumnSize: "medium",
|
|
38
|
+
extraColumns: [
|
|
39
|
+
{
|
|
40
|
+
key: "email",
|
|
41
|
+
label: "Email",
|
|
42
|
+
align: "left",
|
|
43
|
+
size: "100%",
|
|
44
|
+
hideOnScreenSize: "phonemid",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<section
|
|
51
|
+
data-fs-bp-users-table
|
|
52
|
+
className={className}
|
|
53
|
+
aria-busy={disabled ? "true" : "false"}
|
|
54
|
+
>
|
|
55
|
+
<Table layoutFixed>
|
|
56
|
+
<Table.Head columns={columns} />
|
|
57
|
+
|
|
58
|
+
<Table.Body>
|
|
59
|
+
{users.length === 0 ? (
|
|
60
|
+
<Table.Row title={emptyMessage} enabled={false}>
|
|
61
|
+
<Table.Cell />
|
|
62
|
+
</Table.Row>
|
|
63
|
+
) : (
|
|
64
|
+
users.map((u) => (
|
|
65
|
+
<Table.Row
|
|
66
|
+
key={u.userId}
|
|
67
|
+
title={
|
|
68
|
+
currClientId === u.userId ? (
|
|
69
|
+
<span>
|
|
70
|
+
{u.userName}
|
|
71
|
+
<span data-fs-bp-users-you> (you)</span>
|
|
72
|
+
</span>
|
|
73
|
+
) : (
|
|
74
|
+
u.userName
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
enabled={!disabled}
|
|
78
|
+
actionIcons={(() => {
|
|
79
|
+
const rowDisabled =
|
|
80
|
+
disabled || users.length === 1 || !onRemove;
|
|
81
|
+
const button = (
|
|
82
|
+
<button
|
|
83
|
+
type="button"
|
|
84
|
+
data-fs-bp-users-remove
|
|
85
|
+
aria-label={`Remove ${u.userName}`}
|
|
86
|
+
disabled={rowDisabled}
|
|
87
|
+
onClick={() => onRemove?.(u.userId)}
|
|
88
|
+
>
|
|
89
|
+
<Icon name="MinusCircle" width={20} height={20} />
|
|
90
|
+
</button>
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
return rowDisabled && users.length === 1 ? (
|
|
94
|
+
<Tooltip
|
|
95
|
+
placement="left-center"
|
|
96
|
+
content="At least one user must be notified. Add another user before removing this one."
|
|
97
|
+
>
|
|
98
|
+
{button}
|
|
99
|
+
</Tooltip>
|
|
100
|
+
) : (
|
|
101
|
+
button
|
|
102
|
+
);
|
|
103
|
+
})()}
|
|
104
|
+
>
|
|
105
|
+
<Table.Cell>
|
|
106
|
+
<span data-fs-bp-users-email>{u.email}</span>
|
|
107
|
+
</Table.Cell>
|
|
108
|
+
</Table.Row>
|
|
109
|
+
))
|
|
110
|
+
)}
|
|
111
|
+
</Table.Body>
|
|
112
|
+
</Table>
|
|
113
|
+
</section>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export const BudgetUsersTable = memo(BudgetUsersTableBase);
|
|
118
|
+
export default BudgetUsersTable;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
|
|
2
|
+
[data-fs-bp-users-table] {
|
|
3
|
+
@import "../../../shared/components/Table/table.scss";
|
|
4
|
+
display: block;
|
|
5
|
+
gap: 0;
|
|
6
|
+
margin-top: var(--fs-spacing-3);
|
|
7
|
+
width: 100%;
|
|
8
|
+
background: #fff;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
|
|
11
|
+
[data-fs-bp-table] {
|
|
12
|
+
[data-fs-bp-table-head] {
|
|
13
|
+
[data-fs-bp-table-head-row] {
|
|
14
|
+
border-bottom: var(--fs-border-radius-small) solid #e0e0e0;
|
|
15
|
+
|
|
16
|
+
th[data-fs-bp-table-head-column] {
|
|
17
|
+
text-align: start;
|
|
18
|
+
font-weight: var(--fs-text-weight-medium);
|
|
19
|
+
font-size: var(--fs-text-size-1);
|
|
20
|
+
color: #5c5c5c;
|
|
21
|
+
padding: var(--fs-spacing-2) 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
[data-fs-bp-users-you] {
|
|
29
|
+
color: #6b7280;
|
|
30
|
+
margin-left: 0.25rem;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[data-fs-bp-users-email] {
|
|
34
|
+
color: #374151;
|
|
35
|
+
font-size: var(--fs-text-size-1);
|
|
36
|
+
word-break: break-word;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
[data-fs-bp-users-remove] {
|
|
40
|
+
display: inline-flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
justify-content: center;
|
|
43
|
+
|
|
44
|
+
border-radius: 9999px;
|
|
45
|
+
background: #fff;
|
|
46
|
+
color: #111827;
|
|
47
|
+
transition: box-shadow 0.15s ease, background 0.15s ease;
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
|
|
50
|
+
svg {
|
|
51
|
+
color: #000000;
|
|
52
|
+
stroke-width: 1.3rem;
|
|
53
|
+
width: 1.25rem;
|
|
54
|
+
height: 1.25rem;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&[disabled] {
|
|
58
|
+
cursor: not-allowed;
|
|
59
|
+
svg {
|
|
60
|
+
color: #9ca3af;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
|
@@ -20,6 +20,7 @@ interface IBudgetsTable {
|
|
|
20
20
|
onClickEditBudget(budgetId: string): void;
|
|
21
21
|
openDeleteDrawer(budgetId: string): void;
|
|
22
22
|
loading: boolean;
|
|
23
|
+
onClickCreateNotification?(budgetId: string): void;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export function BudgetsTable({
|
|
@@ -28,6 +29,7 @@ export function BudgetsTable({
|
|
|
28
29
|
onClickEditBudget,
|
|
29
30
|
openDeleteDrawer,
|
|
30
31
|
loading,
|
|
32
|
+
onClickCreateNotification,
|
|
31
33
|
}: IBudgetsTable) {
|
|
32
34
|
const budgets = data;
|
|
33
35
|
const route = useRouter();
|
|
@@ -96,6 +98,14 @@ export function BudgetsTable({
|
|
|
96
98
|
<Icon name="Edit" width={20} height={20} />
|
|
97
99
|
<span>Edit settings</span>
|
|
98
100
|
</DropdownItem>
|
|
101
|
+
{onClickCreateNotification && (
|
|
102
|
+
<DropdownItem
|
|
103
|
+
onClick={() => onClickCreateNotification(item.id)}
|
|
104
|
+
>
|
|
105
|
+
<Icon name="Edit" width={20} height={20} />
|
|
106
|
+
<span>Edit notifications</span>
|
|
107
|
+
</DropdownItem>
|
|
108
|
+
)}
|
|
99
109
|
<DropdownItem
|
|
100
110
|
onClick={() => onClickAllocationPage(item.id)}
|
|
101
111
|
>
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { useBuyerPortal } from "../../../shared/hooks";
|
|
11
11
|
import { sortingOptionsAllocations } from "../../../shared/utils";
|
|
12
12
|
import { getKeyByValue } from "../../../shared/utils/getKeyByValue";
|
|
13
|
-
import { useAddAllocations } from "../../hooks";
|
|
13
|
+
import { useAddAllocations } from "../../hooks/useAddAllocations";
|
|
14
14
|
import { useGetAllocations } from "../../hooks/useGetAllocations";
|
|
15
15
|
import { BudgetAllocationsSelection } from "../BudgetAllocationsSelection/BudgetAllocationsSelection";
|
|
16
16
|
|