@vtex/faststore-plugin-buyer-portal 1.1.106 → 1.1.108
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/custom-fields/layouts/CustomFieldsLayout/CustomFieldsLayout.tsx +1 -0
- package/src/features/shared/clients/Auth.ts +25 -0
- package/src/features/shared/clients/Client.ts +11 -1
- package/src/features/shared/components/withErrorBoundary/withErrorBoundary.tsx +7 -6
- package/src/features/shared/services/index.ts +4 -0
- package/src/features/shared/services/validate-access.service.ts +11 -0
- package/src/features/shared/types/AuthRouteProps.ts +5 -0
- package/src/features/shared/types/index.ts +1 -0
- package/src/features/shared/utils/constants.ts +4 -4
- package/src/features/shared/utils/index.ts +5 -0
- package/src/features/shared/utils/withAuth.tsx +31 -0
- package/src/features/shared/utils/withAuthLoader.ts +47 -0
- package/src/features/shared/utils/withAuthProvider.tsx +38 -0
- package/src/features/shared/utils/withBuyerPortal.tsx +24 -0
- package/src/features/shared/utils/withLoaderErrorBoundary.ts +79 -71
- package/src/features/shared/utils/withProviders.tsx +35 -0
- package/src/pages/address-details.tsx +95 -91
- package/src/pages/addresses.tsx +63 -63
- package/src/pages/budgets-details.tsx +44 -43
- package/src/pages/budgets.tsx +58 -56
- package/src/pages/buying-policies.tsx +84 -78
- package/src/pages/buying-policy-details.tsx +43 -44
- package/src/pages/collections.tsx +59 -60
- package/src/pages/cost-centers.tsx +48 -51
- package/src/pages/credit-cards.tsx +44 -49
- package/src/pages/home.tsx +28 -23
- package/src/pages/org-unit-details.tsx +39 -36
- package/src/pages/org-units.tsx +86 -90
- package/src/pages/payment-methods.tsx +41 -42
- package/src/pages/po-numbers.tsx +43 -46
- package/src/pages/profile.tsx +54 -52
- package/src/pages/releases.tsx +43 -41
- package/src/pages/role-details.tsx +57 -60
- package/src/pages/roles.tsx +42 -39
- package/src/pages/user-details.tsx +58 -58
- package/src/pages/users.tsx +83 -80
package/src/pages/releases.tsx
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { getContractDetailsService } from "../features/contracts/services";
|
|
2
2
|
import { CustomFieldsLayout } from "../features/custom-fields/layouts";
|
|
3
3
|
import { getOrgUnitBasicDataService } from "../features/org-units/services";
|
|
4
|
-
import {
|
|
5
|
-
BuyerPortalProvider,
|
|
6
|
-
withErrorBoundary,
|
|
7
|
-
} from "../features/shared/components";
|
|
4
|
+
import { withErrorBoundary } from "../features/shared/components";
|
|
8
5
|
import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
|
|
9
6
|
import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
|
|
10
7
|
import {
|
|
11
8
|
ClientContext,
|
|
12
|
-
getClientContext,
|
|
13
9
|
withLoaderErrorBoundary,
|
|
10
|
+
withAuthLoader,
|
|
11
|
+
withProviders,
|
|
14
12
|
} from "../features/shared/utils";
|
|
15
13
|
import { getUserByIdService } from "../features/users/services";
|
|
16
14
|
|
|
17
15
|
import type { ContractData } from "../features/contracts/types";
|
|
18
16
|
import type { OrgUnitBasicData } from "../features/org-units/types";
|
|
19
|
-
import type { LoaderData } from "../features/shared/types";
|
|
17
|
+
import type { AuthRouteProps, LoaderData } from "../features/shared/types";
|
|
20
18
|
import type { UserData } from "../features/users/types";
|
|
21
19
|
|
|
22
20
|
export type ReleasesPageData = {
|
|
@@ -40,35 +38,37 @@ type OrgUnitsPageQuery = {
|
|
|
40
38
|
|
|
41
39
|
const loaderFunction = async (
|
|
42
40
|
data: LoaderData<OrgUnitsPageQuery>
|
|
43
|
-
): Promise<ReleasesPageData
|
|
44
|
-
const { customerId, cookie, userId, ...clientContext } =
|
|
45
|
-
await getClientContext(data);
|
|
46
|
-
|
|
41
|
+
): Promise<AuthRouteProps<ReleasesPageData>> => {
|
|
47
42
|
const { contractId, orgUnitId } = data.query;
|
|
48
43
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
44
|
+
return withAuthLoader(
|
|
45
|
+
data,
|
|
46
|
+
async ({ customerId, cookie, userId, ...clientContext }) => {
|
|
47
|
+
const [orgUnit, contract, user] = await Promise.all([
|
|
48
|
+
getOrgUnitBasicDataService({
|
|
49
|
+
id: orgUnitId,
|
|
50
|
+
cookie,
|
|
51
|
+
}),
|
|
52
|
+
getContractDetailsService({
|
|
53
|
+
contractId,
|
|
54
|
+
unitId: orgUnitId,
|
|
55
|
+
cookie,
|
|
56
|
+
}),
|
|
57
|
+
getUserByIdService({ orgUnitId, userId, cookie }),
|
|
58
|
+
]);
|
|
61
59
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
60
|
+
return {
|
|
61
|
+
data: contract,
|
|
62
|
+
context: {
|
|
63
|
+
search: "",
|
|
64
|
+
clientContext: { customerId, cookie, userId, ...clientContext },
|
|
65
|
+
currentOrgUnit: orgUnit,
|
|
66
|
+
currentContract: contract,
|
|
67
|
+
currentUser: user,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
@@ -76,21 +76,23 @@ export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
|
76
76
|
redirectToError: true,
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
const ReleasesPage = ({ data,
|
|
79
|
+
const ReleasesPage = ({ data, hasError, error }: ReleasesPageData) => {
|
|
80
80
|
return (
|
|
81
|
-
|
|
81
|
+
<>
|
|
82
82
|
{hasError ? (
|
|
83
83
|
<ErrorTabsLayout error={error} />
|
|
84
84
|
) : (
|
|
85
85
|
<CustomFieldsLayout data={data} customFieldsLabel="Release" />
|
|
86
86
|
)}
|
|
87
|
-
|
|
87
|
+
</>
|
|
88
88
|
);
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
-
export default
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
91
|
+
export default withProviders(
|
|
92
|
+
withErrorBoundary(ReleasesPage, {
|
|
93
|
+
tags: {
|
|
94
|
+
component: "ReleasesPage",
|
|
95
|
+
errorType: "releases_error",
|
|
96
|
+
},
|
|
97
|
+
})
|
|
98
|
+
);
|
|
@@ -2,21 +2,19 @@ import { getOrgUnitBasicDataService } from "../features/org-units/services";
|
|
|
2
2
|
import { RoleDetailsLayout } from "../features/roles/layout";
|
|
3
3
|
import { getRolesAndPermissionsService } from "../features/roles/services";
|
|
4
4
|
import { RolePermission } from "../features/roles/types";
|
|
5
|
-
import {
|
|
6
|
-
BuyerPortalProvider,
|
|
7
|
-
withErrorBoundary,
|
|
8
|
-
} from "../features/shared/components";
|
|
5
|
+
import { withErrorBoundary } from "../features/shared/components";
|
|
9
6
|
import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
|
|
10
7
|
import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
|
|
11
8
|
import {
|
|
12
9
|
type ClientContext,
|
|
13
|
-
getClientContext,
|
|
14
10
|
withLoaderErrorBoundary,
|
|
11
|
+
withAuthLoader,
|
|
12
|
+
withProviders,
|
|
15
13
|
} from "../features/shared/utils";
|
|
16
14
|
import { getUserByIdService } from "../features/users/services";
|
|
17
15
|
|
|
18
16
|
import type { OrgUnitBasicData } from "../features/org-units/types";
|
|
19
|
-
import type { LoaderData } from "../features/shared/types";
|
|
17
|
+
import type { AuthRouteProps, LoaderData } from "../features/shared/types";
|
|
20
18
|
import type { UserData } from "../features/users/types";
|
|
21
19
|
|
|
22
20
|
export type RoleDetailsPageData = {
|
|
@@ -35,36 +33,52 @@ export type RoleDetailsPageData = {
|
|
|
35
33
|
|
|
36
34
|
const loaderFunction = async (
|
|
37
35
|
data: LoaderData
|
|
38
|
-
): Promise<RoleDetailsPageData
|
|
39
|
-
const { cookie, userId, ...clientContext } = await getClientContext(data);
|
|
40
|
-
|
|
36
|
+
): Promise<AuthRouteProps<RoleDetailsPageData>> => {
|
|
41
37
|
const { orgUnitId, roleName } = data.query;
|
|
42
38
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
39
|
+
return withAuthLoader(data, async ({ cookie, userId, ...clientContext }) => {
|
|
40
|
+
const rolesAndPermissions = await getRolesAndPermissionsService({
|
|
41
|
+
customerId: clientContext.customerId,
|
|
42
|
+
unitId: orgUnitId,
|
|
43
|
+
cookie,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const roles = Object.keys(rolesAndPermissions);
|
|
47
|
+
|
|
48
|
+
const cleanRoleName = String(roleName)
|
|
49
|
+
.replace(/-/g, " ")
|
|
50
|
+
.toLocaleLowerCase();
|
|
51
|
+
|
|
52
|
+
const currentRole =
|
|
53
|
+
roles.find((role) => role.toLocaleLowerCase() === cleanRoleName) ?? "";
|
|
54
|
+
|
|
55
|
+
const currentOrgUnit = await getOrgUnitBasicDataService({
|
|
56
|
+
id: orgUnitId,
|
|
57
|
+
cookie,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const user = await getUserByIdService({ orgUnitId, userId, cookie });
|
|
61
|
+
|
|
62
|
+
if (!currentRole) {
|
|
63
|
+
return {
|
|
64
|
+
data: {
|
|
65
|
+
roleName: "Not Found",
|
|
66
|
+
roles: [],
|
|
67
|
+
},
|
|
68
|
+
context: {
|
|
69
|
+
clientContext: { cookie, userId, ...clientContext },
|
|
70
|
+
currentOrgUnit,
|
|
71
|
+
currentUser: user,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const role = rolesAndPermissions[currentRole];
|
|
62
77
|
|
|
63
|
-
if (!currentRole) {
|
|
64
78
|
return {
|
|
65
79
|
data: {
|
|
66
|
-
roleName:
|
|
67
|
-
roles:
|
|
80
|
+
roleName: currentRole,
|
|
81
|
+
roles: role,
|
|
68
82
|
},
|
|
69
83
|
context: {
|
|
70
84
|
clientContext: { cookie, userId, ...clientContext },
|
|
@@ -72,21 +86,7 @@ const loaderFunction = async (
|
|
|
72
86
|
currentUser: user,
|
|
73
87
|
},
|
|
74
88
|
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const role = rolesAndPermissions[currentRole];
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
data: {
|
|
81
|
-
roleName: currentRole,
|
|
82
|
-
roles: role,
|
|
83
|
-
},
|
|
84
|
-
context: {
|
|
85
|
-
clientContext: { cookie, userId, ...clientContext },
|
|
86
|
-
currentOrgUnit,
|
|
87
|
-
currentUser: user,
|
|
88
|
-
},
|
|
89
|
-
};
|
|
89
|
+
});
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
@@ -94,24 +94,21 @@ export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
|
94
94
|
redirectToError: true,
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
-
const RoleDetailsPage = ({
|
|
98
|
-
|
|
99
|
-
context,
|
|
100
|
-
hasError,
|
|
101
|
-
error,
|
|
102
|
-
}: RoleDetailsPageData) => (
|
|
103
|
-
<BuyerPortalProvider {...context}>
|
|
97
|
+
const RoleDetailsPage = ({ data, hasError, error }: RoleDetailsPageData) => (
|
|
98
|
+
<>
|
|
104
99
|
{hasError ? (
|
|
105
100
|
<ErrorTabsLayout error={error} />
|
|
106
101
|
) : (
|
|
107
102
|
<RoleDetailsLayout data={data} />
|
|
108
103
|
)}
|
|
109
|
-
|
|
104
|
+
</>
|
|
110
105
|
);
|
|
111
106
|
|
|
112
|
-
export default
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
107
|
+
export default withProviders(
|
|
108
|
+
withErrorBoundary(RoleDetailsPage, {
|
|
109
|
+
tags: {
|
|
110
|
+
component: "RoleDetailsPage",
|
|
111
|
+
errorType: "role_details_error",
|
|
112
|
+
},
|
|
113
|
+
})
|
|
114
|
+
);
|
package/src/pages/roles.tsx
CHANGED
|
@@ -2,21 +2,19 @@ import { getOrgUnitBasicDataService } from "../features/org-units/services";
|
|
|
2
2
|
import { RolesLayout } from "../features/roles/layout";
|
|
3
3
|
import { getRolesAndPermissionsService } from "../features/roles/services";
|
|
4
4
|
import { RolePermission } from "../features/roles/types";
|
|
5
|
-
import {
|
|
6
|
-
BuyerPortalProvider,
|
|
7
|
-
withErrorBoundary,
|
|
8
|
-
} from "../features/shared/components";
|
|
5
|
+
import { withErrorBoundary } from "../features/shared/components";
|
|
9
6
|
import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
|
|
10
7
|
import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
|
|
11
8
|
import {
|
|
12
9
|
type ClientContext,
|
|
13
|
-
getClientContext,
|
|
14
10
|
withLoaderErrorBoundary,
|
|
11
|
+
withAuthLoader,
|
|
12
|
+
withProviders,
|
|
15
13
|
} from "../features/shared/utils";
|
|
16
14
|
import { getUserByIdService } from "../features/users/services";
|
|
17
15
|
|
|
18
16
|
import type { OrgUnitBasicData } from "../features/org-units/types";
|
|
19
|
-
import type { LoaderData } from "../features/shared/types";
|
|
17
|
+
import type { AuthRouteProps, LoaderData } from "../features/shared/types";
|
|
20
18
|
import type { UserData } from "../features/users/types";
|
|
21
19
|
|
|
22
20
|
export type RolesPageData = {
|
|
@@ -32,33 +30,36 @@ export type RolesPageData = {
|
|
|
32
30
|
error?: ErrorBoundaryProps;
|
|
33
31
|
};
|
|
34
32
|
|
|
35
|
-
const loaderFunction = async (
|
|
36
|
-
|
|
33
|
+
const loaderFunction = async (
|
|
34
|
+
data: LoaderData
|
|
35
|
+
): Promise<AuthRouteProps<RolesPageData>> => {
|
|
37
36
|
const { orgUnitId } = data.query;
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
return withAuthLoader(data, async ({ cookie, userId, ...clientContext }) => {
|
|
39
|
+
const [rolesAndPermissions, currentOrgUnit, user] = await Promise.all([
|
|
40
|
+
getRolesAndPermissionsService({
|
|
41
|
+
unitId: orgUnitId,
|
|
42
|
+
customerId: clientContext.customerId,
|
|
43
|
+
cookie,
|
|
44
|
+
}),
|
|
45
|
+
getOrgUnitBasicDataService({
|
|
46
|
+
id: orgUnitId,
|
|
47
|
+
cookie,
|
|
48
|
+
}),
|
|
49
|
+
getUserByIdService({ orgUnitId, userId, cookie }),
|
|
50
|
+
]);
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
return {
|
|
53
|
+
data: {
|
|
54
|
+
rolesAndPermissions,
|
|
55
|
+
},
|
|
56
|
+
context: {
|
|
57
|
+
clientContext: { cookie, userId, ...clientContext },
|
|
58
|
+
currentOrgUnit,
|
|
59
|
+
currentUser: user,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
});
|
|
62
63
|
};
|
|
63
64
|
|
|
64
65
|
export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
@@ -66,15 +67,17 @@ export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
|
66
67
|
redirectToError: true,
|
|
67
68
|
});
|
|
68
69
|
|
|
69
|
-
const RolesPage = ({ data,
|
|
70
|
-
|
|
70
|
+
const RolesPage = ({ data, hasError, error }: RolesPageData) => (
|
|
71
|
+
<>
|
|
71
72
|
{hasError ? <ErrorTabsLayout error={error} /> : <RolesLayout data={data} />}
|
|
72
|
-
|
|
73
|
+
</>
|
|
73
74
|
);
|
|
74
75
|
|
|
75
|
-
export default
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
76
|
+
export default withProviders(
|
|
77
|
+
withErrorBoundary(RolesPage, {
|
|
78
|
+
tags: {
|
|
79
|
+
component: "RolesPage",
|
|
80
|
+
errorType: "roles_error",
|
|
81
|
+
},
|
|
82
|
+
})
|
|
83
|
+
);
|
|
@@ -3,23 +3,21 @@ import {
|
|
|
3
3
|
getOrgUnitByUserIdService,
|
|
4
4
|
} from "../features/org-units/services";
|
|
5
5
|
import { getRolesIdsService } from "../features/roles/services";
|
|
6
|
-
import {
|
|
7
|
-
BuyerPortalProvider,
|
|
8
|
-
withErrorBoundary,
|
|
9
|
-
} from "../features/shared/components";
|
|
6
|
+
import { withErrorBoundary } from "../features/shared/components";
|
|
10
7
|
import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
|
|
11
8
|
import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
|
|
12
9
|
import {
|
|
13
10
|
type ClientContext,
|
|
14
|
-
getClientContext,
|
|
15
11
|
withLoaderErrorBoundary,
|
|
12
|
+
withAuthLoader,
|
|
13
|
+
withProviders,
|
|
16
14
|
} from "../features/shared/utils";
|
|
17
15
|
import { UserDetailsLayout } from "../features/users/layouts";
|
|
18
16
|
import { getUserByIdService } from "../features/users/services/get-user-by-id.service";
|
|
19
17
|
|
|
20
18
|
import type { OrgUnitBasicData } from "../features/org-units/types";
|
|
21
19
|
import type { RoleData } from "../features/roles/types";
|
|
22
|
-
import type { LoaderData } from "../features/shared/types";
|
|
20
|
+
import type { AuthRouteProps, LoaderData } from "../features/shared/types";
|
|
23
21
|
import type { UserData } from "../features/users/types";
|
|
24
22
|
|
|
25
23
|
type UserDetailsPageQuery = {
|
|
@@ -44,49 +42,54 @@ export type UserDetailsPageData = {
|
|
|
44
42
|
|
|
45
43
|
const loaderFunction = async (
|
|
46
44
|
data: LoaderData<UserDetailsPageQuery>
|
|
47
|
-
): Promise<UserDetailsPageData
|
|
48
|
-
const { cookie, customerId, ...clientContext } = await getClientContext(data);
|
|
49
|
-
|
|
45
|
+
): Promise<AuthRouteProps<UserDetailsPageData>> => {
|
|
50
46
|
const { userId, orgUnitId } = data.query;
|
|
51
47
|
|
|
52
|
-
|
|
48
|
+
return withAuthLoader(
|
|
49
|
+
data,
|
|
50
|
+
async ({ cookie, customerId, ...clientContext }) => {
|
|
51
|
+
const user = await getUserByIdService({ orgUnitId, userId, cookie });
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
if (!user) {
|
|
54
|
+
data.res?.writeHead(302, { Location: "/pvt/organization-account" });
|
|
55
|
+
data.res?.end();
|
|
56
|
+
}
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
58
|
+
const [currentOrgUnit, orgUnitFromUser, rolesOptions] = await Promise.all(
|
|
59
|
+
[
|
|
60
|
+
getOrgUnitBasicDataService({
|
|
61
|
+
id: orgUnitId,
|
|
62
|
+
cookie,
|
|
63
|
+
}),
|
|
64
|
+
getOrgUnitByUserIdService({
|
|
65
|
+
userId,
|
|
66
|
+
cookie,
|
|
67
|
+
}),
|
|
68
|
+
getRolesIdsService({
|
|
69
|
+
unitId: orgUnitId,
|
|
70
|
+
customerId,
|
|
71
|
+
cookie,
|
|
72
|
+
}),
|
|
73
|
+
]
|
|
74
|
+
);
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
76
|
+
return {
|
|
77
|
+
data: {
|
|
78
|
+
user,
|
|
79
|
+
orgUnit: {
|
|
80
|
+
id: orgUnitFromUser?.id ?? "",
|
|
81
|
+
name: orgUnitFromUser?.name ?? "",
|
|
82
|
+
},
|
|
83
|
+
rolesOptions,
|
|
84
|
+
},
|
|
85
|
+
context: {
|
|
86
|
+
clientContext: { cookie, customerId, ...clientContext },
|
|
87
|
+
currentOrgUnit,
|
|
88
|
+
currentUser: user,
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
);
|
|
90
93
|
};
|
|
91
94
|
|
|
92
95
|
export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
@@ -94,24 +97,21 @@ export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
|
94
97
|
redirectToError: true,
|
|
95
98
|
});
|
|
96
99
|
|
|
97
|
-
const UserDetailsPage = ({
|
|
98
|
-
|
|
99
|
-
context,
|
|
100
|
-
hasError,
|
|
101
|
-
error,
|
|
102
|
-
}: UserDetailsPageData) => (
|
|
103
|
-
<BuyerPortalProvider {...context}>
|
|
100
|
+
const UserDetailsPage = ({ data, hasError, error }: UserDetailsPageData) => (
|
|
101
|
+
<>
|
|
104
102
|
{hasError ? (
|
|
105
103
|
<ErrorTabsLayout error={error} />
|
|
106
104
|
) : (
|
|
107
105
|
<UserDetailsLayout data={data} />
|
|
108
106
|
)}
|
|
109
|
-
|
|
107
|
+
</>
|
|
110
108
|
);
|
|
111
109
|
|
|
112
|
-
export default
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
110
|
+
export default withProviders(
|
|
111
|
+
withErrorBoundary(UserDetailsPage, {
|
|
112
|
+
tags: {
|
|
113
|
+
component: "UserDetailsPage",
|
|
114
|
+
errorType: "user_details_error",
|
|
115
|
+
},
|
|
116
|
+
})
|
|
117
|
+
);
|