@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/faststore-plugin-buyer-portal",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
4
4
  "description": "A plugin for faststore with buyer portal",
5
5
  "main": "index.js",
6
6
  "dependencies": {
@@ -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
- firstName: string;
13
- lastName: string;
12
+ name: string;
14
13
  email: string;
15
14
  role: string;
16
15
  orgUnit: string;
17
- }>(`user/${userId}`, {
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
- firstName: string;
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
- }>(`users/${orgUnitId}`, {
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
- `users/${orgUnitId}`,
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
- `users/${orgUnitId}`,
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
- >("user/reassign", props, {
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, firstName, lastName, orgUnit, role } =
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: `${firstName} ${lastName}`,
18
+ name: `${name}`,
17
19
  userType: role,
18
20
  id: userId,
19
21
  email,
@@ -16,7 +16,7 @@ export const getUsersByOrgUnitIdService = async ({
16
16
 
17
17
  return {
18
18
  users: users.map((user) => ({
19
- name: user.firstName,
19
+ name: user.name,
20
20
  userType: user.role,
21
21
  userId: user.userId,
22
22
  email: user.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),
@@ -46,7 +46,7 @@ export async function loader(
46
46
  cookie,
47
47
  });
48
48
 
49
- const user = await getUserByIdService({ userId, cookie });
49
+ const user = await getUserByIdService({ orgUnitId, userId, cookie });
50
50
 
51
51
  const contract = await getContractDetailsService({
52
52
  contractId,
@@ -51,7 +51,7 @@ export async function loader(
51
51
  cookie,
52
52
  });
53
53
 
54
- const user = await getUserByIdService({ userId, cookie });
54
+ const user = await getUserByIdService({ orgUnitId, userId, cookie });
55
55
 
56
56
  const contract = await getContractDetailsService({
57
57
  contractId,
@@ -41,7 +41,7 @@ export async function loader(
41
41
  cookie,
42
42
  });
43
43
 
44
- const user = await getUserByIdService({ userId, cookie });
44
+ const user = await getUserByIdService({ orgUnitId, userId, cookie });
45
45
 
46
46
  const contract = await getContractDetailsService({
47
47
  contractId,
@@ -37,7 +37,7 @@ export async function loader(
37
37
  cookie,
38
38
  });
39
39
 
40
- const user = await getUserByIdService({ userId, cookie });
40
+ const user = await getUserByIdService({ orgUnitId, userId, cookie });
41
41
 
42
42
  const contract = await getContractDetailsService({
43
43
  contractId,
@@ -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,
@@ -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 {
@@ -39,7 +39,7 @@ export async function loader(
39
39
  cookie,
40
40
  });
41
41
 
42
- const user = await getUserByIdService({ userId, cookie });
42
+ const user = await getUserByIdService({ orgUnitId, userId, cookie });
43
43
 
44
44
  return {
45
45
  data: contract,
@@ -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" });
@@ -51,7 +51,7 @@ export async function loader(
51
51
  orgUnitId,
52
52
  });
53
53
 
54
- const user = await getUserByIdService({ userId, cookie });
54
+ const user = await getUserByIdService({ orgUnitId, userId, cookie });
55
55
 
56
56
  const mappedUsers = users.map((user) => ({
57
57
  ...user,