@vtex/faststore-plugin-buyer-portal 1.3.46 → 1.3.48

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 (61) hide show
  1. package/CHANGELOG.md +14 -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 +2 -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/OrgUnitDetailsDropdownMenu/OrgUnitDetailsDropdownMenu.tsx +80 -0
  10. package/src/features/org-units/components/OrgUnitDetailsDropdownMenu/index.ts +4 -0
  11. package/src/features/org-units/components/OrgUnitsDropdownMenu/OrgUnitsDropdownMenu.tsx +2 -2
  12. package/src/features/org-units/components/index.ts +8 -0
  13. package/src/features/org-units/hooks/index.ts +2 -0
  14. package/src/features/org-units/hooks/useGetOrgUnitSettings.ts +20 -0
  15. package/src/features/org-units/hooks/useOrgUnitByUser.ts +4 -1
  16. package/src/features/org-units/hooks/useUpdateOrgUnitSettings.ts +27 -0
  17. package/src/features/org-units/layouts/OrgUnitDetailsLayout/OrgUnitDetailsLayout.tsx +22 -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/product-assortment/hooks/useGetProductAssortment.ts +52 -0
  25. package/src/features/product-assortment/hooks/useGetProductAssortmentFromContract.ts +35 -0
  26. package/src/features/product-assortment/layouts/ProductAssortmentLayout/ProductAssortmentLayout.tsx +55 -12
  27. package/src/features/product-assortment/layouts/ProductAssortmentLayout/product-assortment-layout.scss +1 -1
  28. package/src/features/product-assortment/types/index.ts +6 -14
  29. package/src/features/shared/components/BuyerPortalProvider/BuyerPortalProvider.tsx +5 -0
  30. package/src/features/shared/components/Toast/Toast.tsx +43 -2
  31. package/src/features/shared/components/Toast/toast.scss +23 -5
  32. package/src/features/shared/components/index.ts +1 -0
  33. package/src/features/shared/hooks/usePageItems.ts +2 -2
  34. package/src/features/shared/layouts/ContractTabsLayout/ContractTabsLayout.tsx +1 -0
  35. package/src/features/shared/layouts/LoadingTabsLayout/LoadingTabsLayout.tsx +13 -0
  36. package/src/features/shared/utils/constants.ts +2 -2
  37. package/src/features/shared/utils/withBuyerPortal.tsx +4 -1
  38. package/src/features/users/clients/UsersClient.ts +105 -4
  39. package/src/features/users/components/CreateUserDrawer/CreateUserDrawer.tsx +1 -1
  40. package/src/features/users/components/CreateUserDrawerSelector/CreateUserDrawerSelector.tsx +20 -0
  41. package/src/features/users/components/CreateUserDrawerWithUsername/CreateUserDrawerWithUsername.tsx +696 -0
  42. package/src/features/users/components/CreateUserDrawerWithUsername/create-user-drawer-with-username.scss +116 -0
  43. package/src/features/users/components/UserDropdownMenu/user-dropdown-menu.scss +1 -0
  44. package/src/features/users/components/UsersCard/UsersCard.tsx +2 -2
  45. package/src/features/users/components/index.ts +5 -0
  46. package/src/features/users/hooks/index.ts +2 -0
  47. package/src/features/users/hooks/useAddUserToOrgUnit.ts +12 -5
  48. package/src/features/users/hooks/useResetPassword.ts +39 -0
  49. package/src/features/users/hooks/useValidateUsername.ts +38 -0
  50. package/src/features/users/layouts/UserDetailsLayout/UserDetailsLayout.tsx +10 -0
  51. package/src/features/users/layouts/UsersLayout/UsersLayout.tsx +55 -10
  52. package/src/features/users/layouts/UsersLayout/users-layout.scss +19 -0
  53. package/src/features/users/services/add-user-to-org-unit.service.ts +8 -6
  54. package/src/features/users/services/get-users-by-org-unit-id.service.ts +1 -0
  55. package/src/features/users/services/index.ts +10 -0
  56. package/src/features/users/services/reset-password.service.ts +24 -0
  57. package/src/features/users/services/validate-username.service.ts +25 -0
  58. package/src/features/users/types/UserData.ts +1 -0
  59. package/src/features/users/types/UserDataService.ts +1 -0
  60. package/src/pages/org-unit-details.tsx +20 -2
  61. package/src/pages/productAssortment.tsx +61 -65
@@ -0,0 +1,116 @@
1
+ [data-fs-bp-create-user-drawer] {
2
+ @import "../CreateUserDrawer/create-user-drawer.scss";
3
+
4
+ [data-fs-bp-create-user-2fa-disclaimer] {
5
+ display: flex;
6
+ align-items: flex-start;
7
+ gap: var(--fs-spacing-2);
8
+ padding: var(--fs-spacing-2) var(--fs-spacing-3);
9
+ background-color: #cbe9ff;
10
+ border-radius: var(--fs-border-radius);
11
+ margin-bottom: var(--fs-spacing-3);
12
+
13
+ p {
14
+ font-size: var(--fs-text-size-1);
15
+ color: #000;
16
+ }
17
+ }
18
+
19
+ [data-fs-bp-create-user-userName-suggestions] {
20
+ margin-top: var(--fs-spacing-2);
21
+
22
+ ul {
23
+ list-style: none;
24
+ margin: 0;
25
+ padding: 0;
26
+ display: flex;
27
+ flex-wrap: wrap;
28
+ gap: var(--fs-spacing-0);
29
+
30
+ li {
31
+ button {
32
+ background-color: #f5f5f5;
33
+ border-radius: var(--fs-border-radius-pill);
34
+ padding: var(--fs-spacing-0) var(--fs-spacing-2);
35
+ font-size: var(--fs-text-size-1);
36
+ font-weight: var(--fs-text-weight-semibold);
37
+ color: #000000;
38
+ cursor: pointer;
39
+ }
40
+ }
41
+ }
42
+ }
43
+
44
+ [data-fs-bp-create-user-userName-wrapper] {
45
+ margin-top: var(--fs-spacing-2);
46
+ }
47
+
48
+ [data-fs-bp-create-user-username-suggestions-wrapper] {
49
+ position: relative;
50
+ display: flex;
51
+ width: 100%;
52
+ flex-direction: column;
53
+ justify-content: center;
54
+
55
+ [data-fs-bp-create-user-username-suggestions-icon] {
56
+ cursor: pointer;
57
+ position: absolute;
58
+ top: 0;
59
+ right: 0;
60
+ bottom: 0;
61
+
62
+ [data-fs-button-icon] {
63
+ color: #000000;
64
+ }
65
+ }
66
+
67
+ [data-fs-button-variant="tertiary"]:hover [data-fs-button-wrapper] {
68
+ background-color: transparent;
69
+ }
70
+ }
71
+
72
+ [data-fs-bp-create-user-access-token-body] {
73
+ display: flex;
74
+
75
+ [data-fs-bp-basic-drawer-body-wrapper] {
76
+ display: flex;
77
+ flex-direction: column;
78
+ gap: var(--fs-spacing-4);
79
+ }
80
+
81
+ [data-fs-bp-create-user-access-token-success] {
82
+ display: flex;
83
+ flex-direction: column;
84
+ gap: var(--fs-spacing-2);
85
+
86
+ h3 {
87
+ font-size: var(--fs-bp-text-size-3);
88
+ font-weight: var(--fs-bp-weight-semibold);
89
+ color: #000000;
90
+ letter-spacing: var(--fs-bp-letter-spacing-3);
91
+ }
92
+ }
93
+
94
+ [data-fs-bp-create-user-access-token-description] {
95
+ font-size: var(--fs-bp-text-size-1);
96
+ color: #000000;
97
+ font-weight: var(--fs-bp-weight-regular);
98
+ letter-spacing: var(--fs-bp-letter-spacing-2);
99
+ }
100
+
101
+ [data-fs-bp-create-user-access-token-value] {
102
+ background-color: #f5f5f5;
103
+ border-radius: var(--fs-border-radius);
104
+ padding: var(--fs-spacing-2);
105
+ display: flex;
106
+ align-items: center;
107
+ justify-content: space-between;
108
+
109
+ span {
110
+ font-size: var(--fs-text-size-2);
111
+ font-weight: var(--fs-text-weight-semibold);
112
+ color: #000000;
113
+ }
114
+ }
115
+ }
116
+ }
@@ -2,4 +2,5 @@
2
2
  @import "../ReassignOrgUnitDrawer/reassign-org-unit-drawer.scss";
3
3
  @import "../DeleteUserDrawer/delete-user-drawer.scss";
4
4
  @import "../CreateUserDrawer/create-user-drawer.scss";
5
+ @import "../CreateUserDrawerWithUsername/create-user-drawer-with-userName.scss";
5
6
  @import "../UpdateUserDrawer/update-user-drawer.scss";
@@ -3,7 +3,7 @@ import { Dropdown, DropdownButton } from "@faststore/ui";
3
3
  import { useGetRolesOptions } from "../../../roles/hooks";
4
4
  import { BasicCard, Icon } from "../../../shared/components";
5
5
  import { useDrawerProps } from "../../../shared/hooks";
6
- import { CreateUserDrawer } from "../CreateUserDrawer/CreateUserDrawer";
6
+ import { CreateUserDrawerSelector } from "../CreateUserDrawerSelector/CreateUserDrawerSelector";
7
7
  import { UserDropdownMenu } from "../UserDropdownMenu/UserDropdownMenu";
8
8
 
9
9
  import type { UserSummary } from "../../types";
@@ -68,7 +68,7 @@ export default function UsersCard({ users = [], orgUnitData }: UsersCardProps) {
68
68
  })}
69
69
  </BasicCard>
70
70
  {isCreateUserDrawerOpen && (
71
- <CreateUserDrawer
71
+ <CreateUserDrawerSelector
72
72
  orgUnit={{ id: orgUnitData?.id ?? "", name: orgUnitData?.name ?? "" }}
73
73
  rolesOptions={rolesOptions}
74
74
  isOpen={isCreateUserDrawerOpen}
@@ -3,6 +3,11 @@ export {
3
3
  CreateUserDrawer,
4
4
  type CreateUserDrawerProps,
5
5
  } from "./CreateUserDrawer/CreateUserDrawer";
6
+ export { CreateUserDrawerWithUsername } from "./CreateUserDrawerWithUsername/CreateUserDrawerWithUsername";
7
+ export {
8
+ CreateUserDrawerSelector,
9
+ type CreateUserDrawerSelectorProps,
10
+ } from "./CreateUserDrawerSelector/CreateUserDrawerSelector";
6
11
  export {
7
12
  ReassignOrgUnitDrawer,
8
13
  type ReassignOrgUnitDrawerProps,
@@ -4,3 +4,5 @@ export { useReassignUser } from "./useReassignUser";
4
4
  export { useDebouncedSearchOrgUnit } from "./useDebouncedSearchOrgUnit";
5
5
  export { useUpdateUser } from "./useUpdateUser";
6
6
  export { useGetUserById } from "./useGetUserById";
7
+ export { useValidateUsername } from "./useValidateUsername";
8
+ export { useResetPassword } from "./useResetPassword";
@@ -4,19 +4,26 @@ import {
4
4
  type AddUserToOrgUnitServiceProps,
5
5
  } from "../services";
6
6
 
7
- export const useAddUserToOrgUnit = (
8
- options?: MutationOptions<AwaitedType<typeof addUserToOrgUnitService>>
9
- ) => {
7
+ type UseAddUserToOrgUnitOptions = MutationOptions<
8
+ AwaitedType<typeof addUserToOrgUnitService>
9
+ > & {
10
+ enableUsernameCreation?: boolean;
11
+ };
12
+
13
+ export const useAddUserToOrgUnit = (options?: UseAddUserToOrgUnitOptions) => {
14
+ const { enableUsernameCreation, ...mutationOptions } = options ?? {};
15
+
10
16
  const { mutate, isLoading, error } = useMutation<
11
17
  AwaitedType<typeof addUserToOrgUnitService>,
12
- Omit<AddUserToOrgUnitServiceProps, "cookie">
18
+ Omit<AddUserToOrgUnitServiceProps, "cookie" | "enableUsernameCreation">
13
19
  >(
14
20
  (variables, clientContext) =>
15
21
  addUserToOrgUnitService({
16
22
  ...variables,
17
23
  cookie: clientContext.cookie,
24
+ enableUsernameCreation,
18
25
  }),
19
- options
26
+ mutationOptions
20
27
  );
21
28
  return {
22
29
  addUserToOrgUnit: mutate,
@@ -0,0 +1,39 @@
1
+ import { useCallback } from "react";
2
+
3
+ import { type MutationOptions, useMutation } from "../../shared/hooks";
4
+ import {
5
+ resetPasswordService,
6
+ type ResetPasswordServiceProps,
7
+ type ResetPasswordResponse,
8
+ } from "../services";
9
+
10
+ import type { ClientContext } from "../../shared/utils";
11
+
12
+ export const useResetPassword = (
13
+ options?: MutationOptions<ResetPasswordResponse>
14
+ ) => {
15
+ const mutationFn = useCallback(
16
+ (
17
+ variables: Omit<ResetPasswordServiceProps, "cookie">,
18
+ clientContext: ClientContext
19
+ ) => {
20
+ return resetPasswordService({
21
+ ...variables,
22
+ cookie: clientContext.cookie,
23
+ });
24
+ },
25
+ []
26
+ );
27
+
28
+ const { mutate, isLoading, error, data } = useMutation<
29
+ AwaitedType<typeof resetPasswordService>,
30
+ Omit<ResetPasswordServiceProps, "cookie">
31
+ >(mutationFn, options);
32
+
33
+ return {
34
+ resetPassword: mutate,
35
+ isResetPasswordLoading: isLoading,
36
+ hasResetPasswordError: error,
37
+ accessCode: data?.accessCode,
38
+ };
39
+ };
@@ -0,0 +1,38 @@
1
+ import { useCallback } from "react";
2
+
3
+ import { type MutationOptions, useMutation } from "../../shared/hooks";
4
+ import {
5
+ validateUsernameService,
6
+ type ValidateUsernameServiceProps,
7
+ } from "../services";
8
+
9
+ import type { ClientContext } from "../../shared/utils";
10
+
11
+ export const useValidateUsername = (
12
+ options?: MutationOptions<AwaitedType<typeof validateUsernameService>>
13
+ ) => {
14
+ const mutationFn = useCallback(
15
+ (
16
+ variables: Omit<ValidateUsernameServiceProps, "cookie">,
17
+ clientContext: ClientContext
18
+ ) => {
19
+ return validateUsernameService({
20
+ ...variables,
21
+ cookie: clientContext.cookie,
22
+ });
23
+ },
24
+ []
25
+ );
26
+
27
+ const { mutate, isLoading, error, data } = useMutation<
28
+ AwaitedType<typeof validateUsernameService>,
29
+ Omit<ValidateUsernameServiceProps, "cookie">
30
+ >(mutationFn, options);
31
+
32
+ return {
33
+ validateUsername: mutate,
34
+ isValidateUsernameLoading: isLoading,
35
+ hasValidateUsernameError: error,
36
+ userNameSuggestions: data?.userNameSuggestions ?? [],
37
+ };
38
+ };
@@ -79,6 +79,16 @@ export const UserDetailsLayout = ({
79
79
  <span data-fs-user-details-row-value>{user?.name}</span>
80
80
  </div>
81
81
 
82
+ {user?.userName && (
83
+ <>
84
+ <hr data-fs-user-details-divider />
85
+ <div data-fs-user-details-row>
86
+ <span data-fs-user-details-row-label>Username</span>
87
+ <span data-fs-user-details-row-value>{user?.userName}</span>
88
+ </div>
89
+ </>
90
+ )}
91
+
82
92
  <hr data-fs-user-details-divider />
83
93
 
84
94
  <div data-fs-user-details-row>
@@ -19,7 +19,7 @@ import {
19
19
  import { GlobalLayout } from "../../../shared/layouts";
20
20
  import { OrgUnitTabsLayout } from "../../../shared/layouts/OrgUnitTabsLayout/OrgUnitTabLayout";
21
21
  import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
22
- import { CreateUserDrawer } from "../../components";
22
+ import { CreateUserDrawerSelector } from "../../components";
23
23
  import { UserDropdownMenu } from "../../components/UserDropdownMenu/UserDropdownMenu";
24
24
 
25
25
  import type { UserData } from "../../types";
@@ -55,11 +55,34 @@ export const UsersLayout = ({
55
55
 
56
56
  const columns = getTableColumns({
57
57
  actionsLength: 1,
58
- nameColumnSize: "13.5rem",
58
+ nameColumnLabel: "Username",
59
+ nameColumnKey: "userName",
60
+ nameColumnSize: "12rem",
59
61
  extraColumns: [
60
62
  {
61
- key: "role",
62
- label: "Role",
63
+ key: "fullname",
64
+ label: "Full Name",
65
+ size: "10rem",
66
+ align: "left",
67
+ hideOnScreenSize: "phonemid",
68
+ },
69
+ {
70
+ key: "email",
71
+ label: "Email",
72
+ size: "8rem",
73
+ align: "left",
74
+ hideOnScreenSize: "phonemid",
75
+ },
76
+ {
77
+ key: "phone",
78
+ label: "Phone",
79
+ size: "8rem",
80
+ align: "left",
81
+ hideOnScreenSize: "tablet",
82
+ },
83
+ {
84
+ key: "roles",
85
+ label: "Roles",
63
86
  size: "100%",
64
87
  align: "left",
65
88
  hideOnScreenSize: "phonemid",
@@ -69,7 +92,7 @@ export const UsersLayout = ({
69
92
 
70
93
  const rolesCellLayout = (roles?: string[]) => {
71
94
  if (!roles || roles?.length === 0) {
72
- return null;
95
+ return "-";
73
96
  }
74
97
 
75
98
  const tooltipRoles = roles.slice(1);
@@ -120,9 +143,7 @@ export const UsersLayout = ({
120
143
  items.map((user) => (
121
144
  <Table.Row
122
145
  key={user.id}
123
- title={user.name}
124
- iconName="Profile"
125
- iconSize={24}
146
+ title={user.userName || "-"}
126
147
  href={buyerPortalRoutes.userDetails({
127
148
  orgUnitId: currentOrgUnit?.id ?? "",
128
149
  userId: user.id,
@@ -135,7 +156,30 @@ export const UsersLayout = ({
135
156
  }
136
157
  >
137
158
  <Table.Cell hideOnScreenSize="phonemid">
138
- {rolesCellLayout(user.roles)}
159
+ <div data-fs-bp-table-row-title-content>
160
+ <p data-fs-bp-table-row-title-text>
161
+ {user.name || "-"}
162
+ </p>
163
+ </div>
164
+ </Table.Cell>
165
+ <Table.Cell hideOnScreenSize="phonemid">
166
+ <div data-fs-bp-table-row-title-content>
167
+ <p data-fs-bp-table-row-title-text>
168
+ {user.email || "-"}
169
+ </p>
170
+ </div>
171
+ </Table.Cell>
172
+ <Table.Cell hideOnScreenSize="tablet">
173
+ <div data-fs-bp-table-row-title-content>
174
+ <p data-fs-bp-table-row-title-text>
175
+ {user.phone || "-"}
176
+ </p>
177
+ </div>
178
+ </Table.Cell>
179
+ <Table.Cell hideOnScreenSize="phonemid">
180
+ <div data-fs-bp-table-row-title-content>
181
+ {rolesCellLayout(user.roles)}
182
+ </div>
139
183
  </Table.Cell>
140
184
  </Table.Row>
141
185
  ))
@@ -160,13 +204,14 @@ export const UsersLayout = ({
160
204
  </div>
161
205
 
162
206
  {isCreateUserDrawerOpen && (
163
- <CreateUserDrawer
207
+ <CreateUserDrawerSelector
164
208
  rolesOptions={rolesOptions}
165
209
  orgUnit={{
166
210
  id: currentOrgUnit?.id ?? "",
167
211
  name: currentOrgUnit?.name ?? "",
168
212
  }}
169
213
  isOpen={isCreateUserDrawerOpen}
214
+ onCreate={() => location.reload()}
170
215
  {...createUserDrawerProps}
171
216
  />
172
217
  )}
@@ -15,6 +15,7 @@
15
15
  @import "../../../shared/components/InternalTopbar/internal-top-bar.scss";
16
16
 
17
17
  @import "../../../shared/components/Table/table.scss";
18
+ @import "../../../shared/components/Table/TableCell/table-cell.scss";
18
19
  @import "../../../shared/components/Paginator/paginator.scss";
19
20
 
20
21
  --data-fs-users-table-width: 11.875rem;
@@ -198,6 +199,24 @@
198
199
  [data-fs-bp-table-row] {
199
200
  --fs-spacing-7: 40px;
200
201
 
202
+ [data-fs-bp-table-row-title-content] {
203
+ display: flex;
204
+ align-items: center;
205
+ width: 100%;
206
+ gap: var(--fs-spacing-0);
207
+ }
208
+
209
+ [data-fs-bp-table-row-title-text] {
210
+ font-size: var(--fs-text-size-1);
211
+ font-weight: var(--fs-text-weight-medium);
212
+ line-height: var(--fs-text-size-3);
213
+ flex: 1;
214
+ white-space: nowrap;
215
+ overflow: hidden;
216
+ text-overflow: ellipsis;
217
+ padding-right: var(--fs-spacing-1);
218
+ }
219
+
201
220
  [data-fs-bp-table-user-roles] {
202
221
  display: flex;
203
222
  flex-wrap: wrap;
@@ -3,21 +3,23 @@ import { usersClient } from "../clients/UsersClient";
3
3
  export type AddUserToOrgUnitServiceProps = {
4
4
  orgUnitId: string;
5
5
  roles: number[];
6
- email: string;
7
- name: string;
6
+ email?: string;
7
+ name?: string;
8
8
  phone?: string;
9
+ userName: string;
9
10
  cookie: string;
11
+ enableUsernameCreation?: boolean;
10
12
  };
11
13
 
12
14
  export const addUserToOrgUnitService = async ({
13
15
  cookie,
14
16
  roles,
17
+ enableUsernameCreation,
15
18
  ...data
16
19
  }: AddUserToOrgUnitServiceProps) => {
17
- const response = await usersClient.addUserToOrgUnit(
18
- { ...data, role: roles },
19
- cookie
20
- );
20
+ const response = enableUsernameCreation
21
+ ? await usersClient.addUserToOrgUnitV2({ ...data, role: roles }, cookie)
22
+ : await usersClient.addUserToOrgUnit({ ...data, role: roles }, cookie);
21
23
 
22
24
  if (response.message === "User already exists and is attached to a unit") {
23
25
  throw new Error(JSON.stringify(response));
@@ -17,6 +17,7 @@ export const getUsersByOrgUnitIdService = async (
17
17
  roles: user.role ? user.role : [],
18
18
  email: user.email,
19
19
  orgUnit: { name: user.orgUnit },
20
+ userName: user.userName,
20
21
  })),
21
22
  total,
22
23
  };
@@ -16,3 +16,13 @@ export {
16
16
  type UpdateUserServiceProps,
17
17
  } from "./update-user.service";
18
18
  export { getUserByIdService } from "./get-user-by-id.service";
19
+ export {
20
+ validateUsernameService,
21
+ type ValidateUsernameServiceProps,
22
+ type ValidateUsernameResponse,
23
+ } from "./validate-username.service";
24
+ export {
25
+ resetPasswordService,
26
+ type ResetPasswordServiceProps,
27
+ type ResetPasswordResponse,
28
+ } from "./reset-password.service";
@@ -0,0 +1,24 @@
1
+ import { usersClient } from "../clients/UsersClient";
2
+
3
+ export type ResetPasswordServiceProps = {
4
+ orgUnitId: string;
5
+ userId: string;
6
+ cookie: string;
7
+ };
8
+
9
+ export type ResetPasswordResponse = {
10
+ accessCode: string;
11
+ };
12
+
13
+ export const resetPasswordService = async ({
14
+ orgUnitId,
15
+ userId,
16
+ cookie,
17
+ }: ResetPasswordServiceProps): Promise<ResetPasswordResponse> => {
18
+ const response = await usersClient.resetPassword(
19
+ { orgUnitId, userId },
20
+ cookie
21
+ );
22
+
23
+ return response;
24
+ };
@@ -0,0 +1,25 @@
1
+ import { usersClient } from "../clients/UsersClient";
2
+
3
+ export type ValidateUsernameServiceProps = {
4
+ orgUnitId: string;
5
+ userName: string;
6
+ cookie: string;
7
+ };
8
+
9
+ export type ValidateUsernameResponse = {
10
+ valid: boolean;
11
+ userNameSuggestions?: string[];
12
+ };
13
+
14
+ export const validateUsernameService = async ({
15
+ orgUnitId,
16
+ userName,
17
+ cookie,
18
+ }: ValidateUsernameServiceProps): Promise<ValidateUsernameResponse> => {
19
+ const response = await usersClient.validateUsername(
20
+ { orgUnitId, userName: userName },
21
+ cookie
22
+ );
23
+
24
+ return response;
25
+ };
@@ -1,5 +1,6 @@
1
1
  export type UserData = {
2
2
  name: string;
3
+ userName?: string;
3
4
  phone?: string;
4
5
  isActive?: boolean;
5
6
  id: string;
@@ -5,6 +5,7 @@ export type UserDataService = {
5
5
  phone?: string;
6
6
  role: string[];
7
7
  orgUnit: string;
8
+ userName?: string;
8
9
  };
9
10
 
10
11
  export type GetUsersByOrgUnitIdServiceProps = {
@@ -1,6 +1,10 @@
1
1
  import { getContractsByOrgUnitIdService } from "../features/contracts/services";
2
2
  import { OrgUnitsDetailsLayout } from "../features/org-units/layouts";
3
- import { getOrgUnitBasicDataService } from "../features/org-units/services";
3
+ import {
4
+ getOrgUnitBasicDataService,
5
+ // TODO[2FA]: Uncomment when Authentication settings are ready
6
+ // getOrgUnitSettingsService,
7
+ } from "../features/org-units/services";
4
8
  import { withErrorBoundary } from "../features/shared/components";
5
9
  import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
6
10
  import {
@@ -12,7 +16,11 @@ import {
12
16
  import { getUserByIdService } from "../features/users/services";
13
17
 
14
18
  import type { ContractData } from "../features/contracts/types";
15
- import type { OrgUnitBasicData } from "../features/org-units/types";
19
+ import type {
20
+ OrgUnitBasicData,
21
+ // TODO[2FA]: Uncomment when Authentication settings are ready
22
+ // OrgUnitSettings,
23
+ } from "../features/org-units/types";
16
24
  import type { AuthRouteProps, LoaderData } from "../features/shared/types";
17
25
  import type { UserData } from "../features/users/types";
18
26
 
@@ -21,6 +29,8 @@ export type OrgUnitDetailsPageData = {
21
29
  orgUnit: OrgUnitBasicData;
22
30
  contracts: ContractData[];
23
31
  user: UserData | null;
32
+ // TODO[2FA]: Uncomment when Authentication settings are ready
33
+ // settings: OrgUnitSettings;
24
34
  };
25
35
  context: {
26
36
  clientContext: ClientContext;
@@ -65,11 +75,19 @@ const loaderFunction = async (
65
75
  cookie,
66
76
  });
67
77
 
78
+ // TODO[2FA]: Uncomment when Authentication settings are ready
79
+ // const settings = await getOrgUnitSettingsService({
80
+ // unitId: orgUnitId,
81
+ // cookie,
82
+ // });
83
+
68
84
  return {
69
85
  data: {
70
86
  contracts,
71
87
  orgUnit,
72
88
  user,
89
+ // TODO[2FA]: Uncomment when Authentication settings are ready
90
+ // settings,
73
91
  },
74
92
  context: {
75
93
  clientContext: { cookie, userId, ...clientContext },