@vtex/faststore-plugin-buyer-portal 1.3.45 → 1.3.47

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 (53) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/package.json +1 -1
  3. package/public/buyer-portal-icons.svg +35 -13
  4. package/src/features/org-units/clients/OrgUnitClient.ts +17 -0
  5. package/src/features/org-units/components/AddAllToOrgUnitDropdown/AddAllToOrgUnitDropdown.tsx +5 -2
  6. package/src/features/org-units/components/AuthSetupDrawer/AuthSetupDrawer.tsx +346 -0
  7. package/src/features/org-units/components/AuthSetupDrawer/auth-setup-drawer.scss +138 -0
  8. package/src/features/org-units/components/AuthSetupDrawer/index.ts +1 -0
  9. package/src/features/org-units/components/DeleteOrgUnitDrawer/DeleteOrgUnitDrawer.tsx +30 -5
  10. package/src/features/org-units/components/OrgUnitDetailsDropdownMenu/OrgUnitDetailsDropdownMenu.tsx +80 -0
  11. package/src/features/org-units/components/OrgUnitDetailsDropdownMenu/index.ts +4 -0
  12. package/src/features/org-units/components/OrgUnitsDropdownMenu/OrgUnitsDropdownMenu.tsx +5 -2
  13. package/src/features/org-units/components/index.ts +8 -0
  14. package/src/features/org-units/hooks/index.ts +2 -0
  15. package/src/features/org-units/hooks/useGetOrgUnitSettings.ts +20 -0
  16. package/src/features/org-units/hooks/useUpdateOrgUnitSettings.ts +27 -0
  17. package/src/features/org-units/layouts/OrgUnitDetailsLayout/OrgUnitDetailsLayout.tsx +23 -1
  18. package/src/features/org-units/layouts/OrgUnitDetailsLayout/org-units-details.scss +1 -0
  19. package/src/features/org-units/services/get-org-unit-settings.service.ts +13 -0
  20. package/src/features/org-units/services/index.ts +8 -0
  21. package/src/features/org-units/services/update-org-unit-settings.service.ts +17 -0
  22. package/src/features/org-units/types/OrgUnitSettings.ts +25 -0
  23. package/src/features/org-units/types/index.ts +2 -0
  24. package/src/features/shared/components/BuyerPortalProvider/BuyerPortalProvider.tsx +5 -0
  25. package/src/features/shared/components/Toast/Toast.tsx +43 -2
  26. package/src/features/shared/components/Toast/toast.scss +23 -5
  27. package/src/features/shared/components/index.ts +1 -0
  28. package/src/features/shared/layouts/LoadingTabsLayout/LoadingTabsLayout.tsx +13 -0
  29. package/src/features/shared/utils/constants.ts +2 -2
  30. package/src/features/shared/utils/withBuyerPortal.tsx +4 -1
  31. package/src/features/users/clients/UsersClient.ts +105 -4
  32. package/src/features/users/components/CreateUserDrawer/CreateUserDrawer.tsx +1 -1
  33. package/src/features/users/components/CreateUserDrawerSelector/CreateUserDrawerSelector.tsx +20 -0
  34. package/src/features/users/components/CreateUserDrawerWithUsername/CreateUserDrawerWithUsername.tsx +696 -0
  35. package/src/features/users/components/CreateUserDrawerWithUsername/create-user-drawer-with-username.scss +116 -0
  36. package/src/features/users/components/UserDropdownMenu/user-dropdown-menu.scss +1 -0
  37. package/src/features/users/components/UsersCard/UsersCard.tsx +2 -2
  38. package/src/features/users/components/index.ts +5 -0
  39. package/src/features/users/hooks/index.ts +2 -0
  40. package/src/features/users/hooks/useAddUserToOrgUnit.ts +12 -5
  41. package/src/features/users/hooks/useResetPassword.ts +39 -0
  42. package/src/features/users/hooks/useValidateUsername.ts +38 -0
  43. package/src/features/users/layouts/UserDetailsLayout/UserDetailsLayout.tsx +10 -0
  44. package/src/features/users/layouts/UsersLayout/UsersLayout.tsx +55 -10
  45. package/src/features/users/layouts/UsersLayout/users-layout.scss +19 -0
  46. package/src/features/users/services/add-user-to-org-unit.service.ts +8 -6
  47. package/src/features/users/services/get-users-by-org-unit-id.service.ts +1 -0
  48. package/src/features/users/services/index.ts +10 -0
  49. package/src/features/users/services/reset-password.service.ts +24 -0
  50. package/src/features/users/services/validate-username.service.ts +25 -0
  51. package/src/features/users/types/UserData.ts +1 -0
  52. package/src/features/users/types/UserDataService.ts +1 -0
  53. package/src/pages/org-unit-details.tsx +20 -2
@@ -57,8 +57,9 @@ class UsersClient extends Client {
57
57
  props: {
58
58
  orgUnitId: string;
59
59
  role: number[];
60
- email: string;
61
- name: string;
60
+ email?: string;
61
+ name?: string;
62
+ userName: string;
62
63
  },
63
64
  cookie: string
64
65
  ) {
@@ -78,8 +79,9 @@ class UsersClient extends Client {
78
79
  {
79
80
  orgUnitId: string;
80
81
  role: number[];
81
- email: string;
82
- name: string;
82
+ email?: string;
83
+ name?: string;
84
+ userName: string;
83
85
  }
84
86
  >(
85
87
  `units/${orgUnitId}/users`,
@@ -96,6 +98,54 @@ class UsersClient extends Client {
96
98
  );
97
99
  }
98
100
 
101
+ addUserToOrgUnitV2(
102
+ props: {
103
+ orgUnitId: string;
104
+ role: number[];
105
+ email?: string;
106
+ name?: string;
107
+ phone?: string;
108
+ userName: string;
109
+ },
110
+ cookie: string
111
+ ) {
112
+ const { orgUnitId, ...data } = props;
113
+
114
+ return this.post<
115
+ {
116
+ message:
117
+ | "User already exists and is attached to a unit"
118
+ | "User Created, Sucessfully attached to Org Unit";
119
+ user: {
120
+ id: string;
121
+ email: string;
122
+ name: string;
123
+ };
124
+ accessToken?: string;
125
+ },
126
+ {
127
+ orgUnitId: string;
128
+ role: number[];
129
+ email?: string;
130
+ name?: string;
131
+ phone?: string;
132
+ userName: string;
133
+ }
134
+ >(
135
+ `v2/units/${orgUnitId}/users`,
136
+ {
137
+ ...data,
138
+ orgUnitId,
139
+ },
140
+ {
141
+ headers: {
142
+ Cookie: cookie,
143
+ },
144
+ ignoreContentType: true,
145
+ }
146
+ );
147
+ }
148
+
99
149
  removeUserFromOrgUnit(
100
150
  props: {
101
151
  orgUnitId: string;
@@ -169,6 +219,57 @@ class UsersClient extends Client {
169
219
  }
170
220
  );
171
221
  }
222
+
223
+ validateUsername(
224
+ props: {
225
+ orgUnitId: string;
226
+ userName: string;
227
+ },
228
+ cookie: string
229
+ ) {
230
+ const { orgUnitId, userName } = props;
231
+
232
+ return this.post<
233
+ {
234
+ valid: boolean;
235
+ userNameSuggestions?: string[];
236
+ },
237
+ {
238
+ userName: string;
239
+ }
240
+ >(
241
+ `units/${orgUnitId}/users/validate`,
242
+ {
243
+ userName,
244
+ },
245
+ {
246
+ headers: {
247
+ Cookie: cookie,
248
+ },
249
+ }
250
+ );
251
+ }
252
+
253
+ resetPassword(
254
+ props: {
255
+ orgUnitId: string;
256
+ userId: string;
257
+ },
258
+ cookie: string
259
+ ) {
260
+ const { orgUnitId, userId } = props;
261
+
262
+ return this.post<
263
+ {
264
+ accessCode: string;
265
+ },
266
+ null
267
+ >(`units/${orgUnitId}/users/${userId}/reset-password`, null, {
268
+ headers: {
269
+ Cookie: cookie,
270
+ },
271
+ });
272
+ }
172
273
  }
173
274
 
174
275
  const usersClient = new UsersClient();
@@ -166,13 +166,13 @@ export const CreateUserDrawer = ({
166
166
  return;
167
167
  }
168
168
 
169
- // Create User
170
169
  addUserToOrgUnit({
171
170
  name,
172
171
  email,
173
172
  phone: phone ?? "",
174
173
  roles,
175
174
  orgUnitId,
175
+ userName: "",
176
176
  });
177
177
  };
178
178
 
@@ -0,0 +1,20 @@
1
+ import { useBuyerPortal } from "../../../shared/hooks";
2
+ import {
3
+ CreateUserDrawer,
4
+ type CreateUserDrawerProps,
5
+ } from "../CreateUserDrawer/CreateUserDrawer";
6
+ import { CreateUserDrawerWithUsername } from "../CreateUserDrawerWithUsername/CreateUserDrawerWithUsername";
7
+
8
+ export type CreateUserDrawerSelectorProps = CreateUserDrawerProps;
9
+
10
+ export const CreateUserDrawerSelector = (
11
+ props: CreateUserDrawerSelectorProps
12
+ ) => {
13
+ const { featureFlags } = useBuyerPortal();
14
+
15
+ if (featureFlags?.enableUsernameCreation) {
16
+ return <CreateUserDrawerWithUsername {...props} />;
17
+ }
18
+
19
+ return <CreateUserDrawer {...props} />;
20
+ };