@vtex/faststore-plugin-buyer-portal 1.0.41 → 1.0.42
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/package.json +1 -1
- package/src/features/users/clients/UsersClient.ts +8 -10
- package/src/features/users/services/get-user-by-id.service.ts +5 -3
- package/src/features/users/services/get-users-by-org-unit-id.service.ts +1 -1
- package/src/pages/address-details.tsx +1 -1
- package/src/pages/addresses.tsx +1 -1
- package/src/pages/buying-policies.tsx +1 -1
- package/src/pages/buying-policy-details.tsx +1 -1
- package/src/pages/credit-cards.tsx +1 -1
- package/src/pages/org-unit-details.tsx +1 -1
- package/src/pages/org-units.tsx +3 -2
- package/src/pages/profile.tsx +1 -1
- package/src/pages/user-details.tsx +1 -1
- package/src/pages/users.tsx +1 -1
package/package.json
CHANGED
|
@@ -6,15 +6,14 @@ class UsersClient extends Client {
|
|
|
6
6
|
super(getApiUrl());
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
getUserById(userId: string, cookie: string) {
|
|
9
|
+
getUserById(orgUnitId: string, userId: string, cookie: string) {
|
|
10
10
|
return this.get<{
|
|
11
11
|
userId: string;
|
|
12
|
-
|
|
13
|
-
lastName: string;
|
|
12
|
+
name: string;
|
|
14
13
|
email: string;
|
|
15
14
|
role: string;
|
|
16
15
|
orgUnit: string;
|
|
17
|
-
}>(`
|
|
16
|
+
}>(`units/${orgUnitId}/users/${userId}`, {
|
|
18
17
|
headers: {
|
|
19
18
|
Cookie: cookie,
|
|
20
19
|
},
|
|
@@ -25,14 +24,13 @@ class UsersClient extends Client {
|
|
|
25
24
|
return this.get<{
|
|
26
25
|
users: {
|
|
27
26
|
userId: string;
|
|
28
|
-
|
|
29
|
-
lastName: string;
|
|
27
|
+
name: string;
|
|
30
28
|
email: string;
|
|
31
29
|
role: string;
|
|
32
30
|
orgUnit: string;
|
|
33
31
|
}[];
|
|
34
32
|
total: number;
|
|
35
|
-
}>(`
|
|
33
|
+
}>(`units/${orgUnitId}/users`, {
|
|
36
34
|
headers: {
|
|
37
35
|
Cookie: cookie,
|
|
38
36
|
},
|
|
@@ -68,7 +66,7 @@ class UsersClient extends Client {
|
|
|
68
66
|
name: string;
|
|
69
67
|
}
|
|
70
68
|
>(
|
|
71
|
-
`
|
|
69
|
+
`units/${orgUnitId}/users`,
|
|
72
70
|
{
|
|
73
71
|
...data,
|
|
74
72
|
orgUnitId,
|
|
@@ -92,7 +90,7 @@ class UsersClient extends Client {
|
|
|
92
90
|
const { orgUnitId, ...data } = props;
|
|
93
91
|
|
|
94
92
|
return this.delete<unknown, { userId: string }>(
|
|
95
|
-
`
|
|
93
|
+
`units/${orgUnitId}/users`,
|
|
96
94
|
data,
|
|
97
95
|
{
|
|
98
96
|
headers: {
|
|
@@ -117,7 +115,7 @@ class UsersClient extends Client {
|
|
|
117
115
|
oldUnitId: string;
|
|
118
116
|
newUnitId: string;
|
|
119
117
|
}
|
|
120
|
-
>(
|
|
118
|
+
>(`units/${props.oldUnitId}/users/reassign`, props, {
|
|
121
119
|
headers: {
|
|
122
120
|
Cookie: cookie,
|
|
123
121
|
},
|
|
@@ -2,18 +2,20 @@ import { usersClient } from "../clients/UsersClient";
|
|
|
2
2
|
import type { UserData } from "../types";
|
|
3
3
|
|
|
4
4
|
export const getUserByIdService = async ({
|
|
5
|
+
orgUnitId,
|
|
5
6
|
userId,
|
|
6
7
|
cookie,
|
|
7
8
|
}: {
|
|
9
|
+
orgUnitId: string;
|
|
8
10
|
userId: string;
|
|
9
11
|
cookie: string;
|
|
10
12
|
}): Promise<UserData | null> => {
|
|
11
13
|
try {
|
|
12
|
-
const { email,
|
|
13
|
-
await usersClient.getUserById(userId, cookie);
|
|
14
|
+
const { email, name, orgUnit, role } =
|
|
15
|
+
await usersClient.getUserById(orgUnitId, userId, cookie);
|
|
14
16
|
|
|
15
17
|
return {
|
|
16
|
-
name: `${
|
|
18
|
+
name: `${name}`,
|
|
17
19
|
userType: role,
|
|
18
20
|
id: userId,
|
|
19
21
|
email,
|
|
@@ -42,7 +42,7 @@ export async function loader(
|
|
|
42
42
|
cookie,
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
const user = await getUserByIdService({ userId, cookie });
|
|
45
|
+
const user = await getUserByIdService({ orgUnitId, userId, cookie });
|
|
46
46
|
|
|
47
47
|
return {
|
|
48
48
|
data: await getAddressDetailsService(addressId, cookie),
|
package/src/pages/addresses.tsx
CHANGED
|
@@ -34,7 +34,7 @@ export async function loader(
|
|
|
34
34
|
cookie,
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
const user = await getUserByIdService({ userId, cookie });
|
|
37
|
+
const user = await getUserByIdService({ orgUnitId, userId, cookie });
|
|
38
38
|
|
|
39
39
|
const contracts = await getContractsByOrgUnitIdService({
|
|
40
40
|
orgUnitId,
|
package/src/pages/org-units.tsx
CHANGED
|
@@ -36,12 +36,14 @@ export async function loader(
|
|
|
36
36
|
const { cookie, customerId, userId, ...restClientContext } =
|
|
37
37
|
await getClientContext(data);
|
|
38
38
|
|
|
39
|
+
const { search, orgUnitId } = data.query;
|
|
40
|
+
|
|
39
41
|
const currentOrgUnit = await getOrgUnitBasicDataService({
|
|
40
42
|
id: data.query.orgUnitId,
|
|
41
43
|
cookie,
|
|
42
44
|
});
|
|
43
45
|
|
|
44
|
-
const user = await getUserByIdService({ userId, cookie });
|
|
46
|
+
const user = await getUserByIdService({ orgUnitId, userId, cookie });
|
|
45
47
|
|
|
46
48
|
const clientContext = {
|
|
47
49
|
cookie,
|
|
@@ -50,7 +52,6 @@ export async function loader(
|
|
|
50
52
|
...restClientContext,
|
|
51
53
|
};
|
|
52
54
|
|
|
53
|
-
const { search, orgUnitId } = data.query;
|
|
54
55
|
|
|
55
56
|
if (search) {
|
|
56
57
|
return {
|
package/src/pages/profile.tsx
CHANGED
|
@@ -36,7 +36,7 @@ export async function loader(
|
|
|
36
36
|
|
|
37
37
|
const { userId, orgUnitId } = data.query;
|
|
38
38
|
|
|
39
|
-
const user = await getUserByIdService({ userId, cookie });
|
|
39
|
+
const user = await getUserByIdService({ orgUnitId, userId, cookie });
|
|
40
40
|
|
|
41
41
|
if (!user) {
|
|
42
42
|
data.res?.writeHead(302, { Location: "/buyer-portal" });
|
package/src/pages/users.tsx
CHANGED