@vtex/faststore-plugin-buyer-portal 1.1.107 → 1.1.109

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 (35) hide show
  1. package/package.json +1 -1
  2. package/src/features/custom-fields/layouts/CustomFieldsLayout/CustomFieldsLayout.tsx +1 -0
  3. package/src/features/shared/clients/Auth.ts +25 -0
  4. package/src/features/shared/clients/Client.ts +11 -1
  5. package/src/features/shared/services/index.ts +4 -0
  6. package/src/features/shared/services/validate-access.service.ts +11 -0
  7. package/src/features/shared/types/AuthRouteProps.ts +5 -0
  8. package/src/features/shared/types/index.ts +1 -0
  9. package/src/features/shared/utils/constants.ts +1 -1
  10. package/src/features/shared/utils/index.ts +5 -0
  11. package/src/features/shared/utils/withAuth.tsx +31 -0
  12. package/src/features/shared/utils/withAuthLoader.ts +47 -0
  13. package/src/features/shared/utils/withAuthProvider.tsx +38 -0
  14. package/src/features/shared/utils/withBuyerPortal.tsx +24 -0
  15. package/src/features/shared/utils/withProviders.tsx +35 -0
  16. package/src/pages/address-details.tsx +95 -91
  17. package/src/pages/addresses.tsx +63 -63
  18. package/src/pages/budgets-details.tsx +44 -43
  19. package/src/pages/budgets.tsx +58 -56
  20. package/src/pages/buying-policies.tsx +84 -78
  21. package/src/pages/buying-policy-details.tsx +43 -44
  22. package/src/pages/collections.tsx +59 -60
  23. package/src/pages/cost-centers.tsx +48 -51
  24. package/src/pages/credit-cards.tsx +44 -49
  25. package/src/pages/home.tsx +28 -23
  26. package/src/pages/org-unit-details.tsx +39 -36
  27. package/src/pages/org-units.tsx +86 -90
  28. package/src/pages/payment-methods.tsx +41 -42
  29. package/src/pages/po-numbers.tsx +43 -46
  30. package/src/pages/profile.tsx +54 -52
  31. package/src/pages/releases.tsx +43 -41
  32. package/src/pages/role-details.tsx +57 -60
  33. package/src/pages/roles.tsx +42 -39
  34. package/src/pages/user-details.tsx +58 -58
  35. package/src/pages/users.tsx +83 -80
@@ -5,24 +5,22 @@ import {
5
5
  } from "../features/addresses/services";
6
6
  import { getContractDetailsService } from "../features/contracts/services";
7
7
  import { getOrgUnitBasicDataService } from "../features/org-units/services";
8
- import {
9
- BuyerPortalProvider,
10
- withErrorBoundary,
11
- } from "../features/shared/components";
8
+ import { withErrorBoundary } from "../features/shared/components";
12
9
  import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
13
10
  import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
14
11
  import {
15
12
  type ClientContext,
16
- getClientContext,
17
13
  getValidPage,
18
14
  withLoaderErrorBoundary,
15
+ withAuthLoader,
16
+ withProviders,
19
17
  } from "../features/shared/utils";
20
18
  import { getUserByIdService } from "../features/users/services";
21
19
 
22
20
  import type { AddressData } from "../features/addresses/types";
23
21
  import type { ContractData } from "../features/contracts/types";
24
22
  import type { OrgUnitBasicData } from "../features/org-units/types";
25
- import type { LoaderData } from "../features/shared/types";
23
+ import type { AuthRouteProps, LoaderData } from "../features/shared/types";
26
24
  import type { UserData } from "../features/users/types";
27
25
 
28
26
  export type AddressesPageData = {
@@ -48,62 +46,63 @@ export type AddressesPageQuery = GetAddressesServiceProps & {
48
46
 
49
47
  const loaderFunction = async (
50
48
  data: LoaderData<AddressesPageQuery>
51
- ): Promise<AddressesPageData> => {
49
+ ): Promise<AuthRouteProps<AddressesPageData>> => {
52
50
  const { contractId, orgUnitId, search, page: pageString } = data.query;
53
51
 
54
52
  const page = getValidPage(pageString);
55
53
 
56
- const { cookie, userId, customerId, ...clientContext } =
57
- await getClientContext(data);
54
+ return withAuthLoader(
55
+ data,
56
+ async ({ cookie, userId, customerId, ...clientContext }) => {
57
+ if (!contractId || !orgUnitId) {
58
+ return {
59
+ data: [],
60
+ search: search ?? "",
61
+ total: 0,
62
+ page: page ?? 1,
63
+ context: {
64
+ clientContext: { customerId, cookie, userId, ...clientContext },
65
+ currentOrgUnit: null,
66
+ currentContract: null,
67
+ currentUser: null,
68
+ },
69
+ };
70
+ }
58
71
 
59
- if (!contractId || !orgUnitId) {
60
- return {
61
- data: [],
62
- search: search ?? "",
63
- total: 0,
64
- page: page ?? 1,
65
- context: {
66
- clientContext: { customerId, cookie, userId, ...clientContext },
67
- currentOrgUnit: null,
68
- currentContract: null,
69
- currentUser: null,
70
- },
71
- };
72
- }
72
+ const [currentOrgUnit, user, contract, addressesResponse] =
73
+ await Promise.all([
74
+ getOrgUnitBasicDataService({
75
+ id: orgUnitId,
76
+ cookie,
77
+ }),
78
+ getUserByIdService({ orgUnitId, userId, cookie }),
79
+ getContractDetailsService({
80
+ contractId,
81
+ cookie,
82
+ unitId: orgUnitId,
83
+ }),
84
+ getAddressesByUnitIdService({
85
+ orgUnitId,
86
+ search,
87
+ page,
88
+ cookie,
89
+ }),
90
+ ]);
73
91
 
74
- const [currentOrgUnit, user, contract, addressesResponse] = await Promise.all(
75
- [
76
- getOrgUnitBasicDataService({
77
- id: orgUnitId,
78
- cookie,
79
- }),
80
- getUserByIdService({ orgUnitId, userId, cookie }),
81
- getContractDetailsService({
82
- contractId,
83
- cookie,
84
- unitId: orgUnitId,
85
- }),
86
- getAddressesByUnitIdService({
87
- orgUnitId,
88
- search,
92
+ return {
93
+ data: addressesResponse.data,
94
+ total: addressesResponse.total,
89
95
  page,
90
- cookie,
91
- }),
92
- ]
96
+ search: search ?? "",
97
+ context: {
98
+ clientContext: { cookie, userId, customerId, ...clientContext },
99
+ currentOrgUnit,
100
+ currentUser: user,
101
+ currentContract: contract,
102
+ },
103
+ };
104
+ }
93
105
  );
94
-
95
- return {
96
- data: addressesResponse.data,
97
- total: addressesResponse.total,
98
- page,
99
- search: search ?? "",
100
- context: {
101
- clientContext: { cookie, userId, customerId, ...clientContext },
102
- currentOrgUnit,
103
- currentUser: user,
104
- currentContract: contract,
105
- },
106
- };
107
106
  };
108
107
 
109
108
  export const loader = withLoaderErrorBoundary(loaderFunction, {
@@ -116,11 +115,10 @@ const AddressPage = ({
116
115
  search,
117
116
  page,
118
117
  total,
119
- context,
120
118
  hasError,
121
119
  error,
122
120
  }: AddressesPageData) => (
123
- <BuyerPortalProvider {...context}>
121
+ <>
124
122
  {hasError ? (
125
123
  <ErrorTabsLayout error={error} />
126
124
  ) : (
@@ -131,12 +129,14 @@ const AddressPage = ({
131
129
  total={total}
132
130
  />
133
131
  )}
134
- </BuyerPortalProvider>
132
+ </>
135
133
  );
136
134
 
137
- export default withErrorBoundary(AddressPage, {
138
- tags: {
139
- component: "AddressesPage",
140
- errorType: "addresses_error",
141
- },
142
- });
135
+ export default withProviders(
136
+ withErrorBoundary(AddressPage, {
137
+ tags: {
138
+ component: "AddressesPage",
139
+ errorType: "addresses_error",
140
+ },
141
+ })
142
+ );
@@ -3,22 +3,20 @@ import { getBudgetByIdService } from "../features/budgets/services";
3
3
  import { Budget } from "../features/budgets/types";
4
4
  import { getContractDetailsService } from "../features/contracts/services";
5
5
  import { getOrgUnitBasicDataService } from "../features/org-units/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 { getUserByIdService } from "../features/users/services";
18
16
 
19
17
  import type { ContractData } from "../features/contracts/types";
20
18
  import type { OrgUnitBasicData } from "../features/org-units/types";
21
- import type { LoaderData } from "../features/shared/types";
19
+ import type { AuthRouteProps, LoaderData } from "../features/shared/types";
22
20
  import type { UserData } from "../features/users/types";
23
21
 
24
22
  export type BudgetsDetailsData = {
@@ -41,37 +39,39 @@ export type BudgetsDetailsQuery = {
41
39
 
42
40
  const loaderFunction = async (
43
41
  data: LoaderData<BudgetsDetailsQuery>
44
- ): Promise<BudgetsDetailsData> => {
45
- const { customerId, cookie, userId, ...clientContext } =
46
- await getClientContext(data);
47
-
42
+ ): Promise<AuthRouteProps<BudgetsDetailsData>> => {
48
43
  const { contractId, orgUnitId, budgetId } = data.query;
49
44
 
50
- const [orgUnit, contract, user, budgetsData] = await Promise.all([
51
- getOrgUnitBasicDataService({ cookie, id: orgUnitId }),
52
- getContractDetailsService({
53
- contractId,
54
- cookie,
55
- unitId: orgUnitId,
56
- }),
57
- getUserByIdService({ orgUnitId, userId, cookie }),
58
- getBudgetByIdService({
59
- budgetId,
60
- customerId,
61
- unitId: orgUnitId,
62
- cookie,
63
- }),
64
- ]);
45
+ return withAuthLoader(
46
+ data,
47
+ async ({ customerId, cookie, userId, ...clientContext }) => {
48
+ const [orgUnit, contract, user, budgetsData] = await Promise.all([
49
+ getOrgUnitBasicDataService({ cookie, id: orgUnitId }),
50
+ getContractDetailsService({
51
+ contractId,
52
+ cookie,
53
+ unitId: orgUnitId,
54
+ }),
55
+ getUserByIdService({ orgUnitId, userId, cookie }),
56
+ getBudgetByIdService({
57
+ budgetId,
58
+ customerId,
59
+ unitId: orgUnitId,
60
+ cookie,
61
+ }),
62
+ ]);
65
63
 
66
- return {
67
- budget: budgetsData,
68
- context: {
69
- clientContext: { customerId, cookie, userId, ...clientContext },
70
- currentOrgUnit: orgUnit,
71
- currentContract: contract,
72
- currentUser: user,
73
- },
74
- };
64
+ return {
65
+ budget: budgetsData,
66
+ context: {
67
+ clientContext: { customerId, cookie, userId, ...clientContext },
68
+ currentOrgUnit: orgUnit,
69
+ currentContract: contract,
70
+ currentUser: user,
71
+ },
72
+ };
73
+ }
74
+ );
75
75
  };
76
76
 
77
77
  export const loader = withLoaderErrorBoundary(loaderFunction, {
@@ -81,22 +81,23 @@ export const loader = withLoaderErrorBoundary(loaderFunction, {
81
81
 
82
82
  const BudgetsDetailsPage = ({
83
83
  budget,
84
- context,
85
84
  hasError,
86
85
  error,
87
86
  }: BudgetsDetailsData) => (
88
- <BuyerPortalProvider {...context}>
87
+ <>
89
88
  {hasError ? (
90
89
  <ErrorTabsLayout error={error} />
91
90
  ) : (
92
91
  <BudgetsDetailsLayout budget={budget} />
93
92
  )}
94
- </BuyerPortalProvider>
93
+ </>
95
94
  );
96
95
 
97
- export default withErrorBoundary(BudgetsDetailsPage, {
98
- tags: {
99
- component: "BudgetsDetailsPage",
100
- errorType: "budgets_details_error",
101
- },
102
- });
96
+ export default withProviders(
97
+ withErrorBoundary(BudgetsDetailsPage, {
98
+ tags: {
99
+ component: "BudgetsDetailsPage",
100
+ errorType: "budgets_details_error",
101
+ },
102
+ })
103
+ );
@@ -2,23 +2,21 @@ import { BudgetsLayout } from "../features/budgets/layouts";
2
2
  import { listBudgetsService } from "../features/budgets/services";
3
3
  import { getContractDetailsService } from "../features/contracts/services";
4
4
  import { getOrgUnitBasicDataService } from "../features/org-units/services";
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 { BudgetListResponse } from "../features/budgets/types";
19
17
  import type { ContractData } from "../features/contracts/types";
20
18
  import type { OrgUnitBasicData } from "../features/org-units/types";
21
- import type { LoaderData } from "../features/shared/types";
19
+ import type { AuthRouteProps, LoaderData } from "../features/shared/types";
22
20
  import type { UserData } from "../features/users/types";
23
21
 
24
22
  export type BudgetPageData = {
@@ -40,51 +38,53 @@ export type BudgetPageQuery = {
40
38
 
41
39
  const loaderFunction = async (
42
40
  data: LoaderData<BudgetPageQuery>
43
- ): Promise<BudgetPageData> => {
44
- const { customerId, cookie, userId, ...clientContext } =
45
- await getClientContext(data);
46
-
41
+ ): Promise<AuthRouteProps<BudgetPageData>> => {
47
42
  const { contractId, orgUnitId } = data.query;
48
43
 
49
- if (!contractId || !orgUnitId) {
50
- return {
51
- data: { data: [], total: 0 },
52
- context: {
53
- clientContext: { cookie, userId, customerId, ...clientContext },
54
- currentOrgUnit: null,
55
- currentContract: null,
56
- currentUser: null,
57
- },
58
- };
59
- }
44
+ return withAuthLoader(
45
+ data,
46
+ async ({ customerId, cookie, userId, ...clientContext }) => {
47
+ if (!contractId || !orgUnitId) {
48
+ return {
49
+ data: { data: [], total: 0 },
50
+ context: {
51
+ clientContext: { customerId, cookie, userId, ...clientContext },
52
+ currentOrgUnit: null,
53
+ currentContract: null,
54
+ currentUser: null,
55
+ },
56
+ };
57
+ }
60
58
 
61
- const [orgUnit, contract, user, budgetsData] = await Promise.all([
62
- getOrgUnitBasicDataService({
63
- cookie,
64
- id: orgUnitId,
65
- }),
66
- getContractDetailsService({
67
- contractId,
68
- unitId: orgUnitId,
69
- cookie,
70
- }),
71
- getUserByIdService({ orgUnitId, userId, cookie }),
72
- listBudgetsService({
73
- customerId,
74
- cookie,
75
- unitId: orgUnitId,
76
- }),
77
- ]);
59
+ const [orgUnit, contract, user, budgetsData] = await Promise.all([
60
+ getOrgUnitBasicDataService({
61
+ cookie,
62
+ id: orgUnitId,
63
+ }),
64
+ getContractDetailsService({
65
+ contractId,
66
+ unitId: orgUnitId,
67
+ cookie,
68
+ }),
69
+ getUserByIdService({ orgUnitId, userId, cookie }),
70
+ listBudgetsService({
71
+ customerId,
72
+ cookie,
73
+ unitId: orgUnitId,
74
+ }),
75
+ ]);
78
76
 
79
- return {
80
- data: budgetsData,
81
- context: {
82
- clientContext: { customerId, cookie, userId, ...clientContext },
83
- currentOrgUnit: orgUnit,
84
- currentContract: contract,
85
- currentUser: user,
86
- },
87
- };
77
+ return {
78
+ data: budgetsData,
79
+ context: {
80
+ clientContext: { customerId, cookie, userId, ...clientContext },
81
+ currentOrgUnit: orgUnit,
82
+ currentContract: contract,
83
+ currentUser: user,
84
+ },
85
+ };
86
+ }
87
+ );
88
88
  };
89
89
 
90
90
  export const loader = withLoaderErrorBoundary(loaderFunction, {
@@ -92,19 +92,21 @@ export const loader = withLoaderErrorBoundary(loaderFunction, {
92
92
  redirectToError: true,
93
93
  });
94
94
 
95
- const ContractsPage = ({ data, context, hasError, error }: BudgetPageData) => (
96
- <BuyerPortalProvider {...context}>
95
+ const ContractsPage = ({ data, hasError, error }: BudgetPageData) => (
96
+ <>
97
97
  {hasError ? (
98
98
  <ErrorTabsLayout error={error} />
99
99
  ) : (
100
100
  <BudgetsLayout data={data} />
101
101
  )}
102
- </BuyerPortalProvider>
102
+ </>
103
103
  );
104
104
 
105
- export default withErrorBoundary(ContractsPage, {
106
- tags: {
107
- component: "BudgetsPage",
108
- errorType: "budgets_error",
109
- },
110
- });
105
+ export default withProviders(
106
+ withErrorBoundary(ContractsPage, {
107
+ tags: {
108
+ component: "BudgetsPage",
109
+ errorType: "budgets_error",
110
+ },
111
+ })
112
+ );
@@ -3,17 +3,15 @@ import { BuyingPoliciesLayout } from "../features/buying-policies/layouts";
3
3
  import { getBuyingPoliciesService } from "../features/buying-policies/services";
4
4
  import { getContractDetailsService } from "../features/contracts/services";
5
5
  import { getOrgUnitBasicDataService } from "../features/org-units/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
  getValidPage,
16
12
  withLoaderErrorBoundary,
13
+ withAuthLoader,
14
+ withProviders,
17
15
  } from "../features/shared/utils";
18
16
  import { getUserByIdService } from "../features/users/services";
19
17
 
@@ -22,7 +20,7 @@ import type { BudgetListResponse } from "../features/budgets/types";
22
20
  import type { BuyingPolicy } from "../features/buying-policies/types";
23
21
  import type { ContractData } from "../features/contracts/types";
24
22
  import type { OrgUnitBasicData } from "../features/org-units/types";
25
- import type { LoaderData } from "../features/shared/types";
23
+ import type { AuthRouteProps, LoaderData } from "../features/shared/types";
26
24
  import type { UserData } from "../features/users/types";
27
25
 
28
26
  export type BuyingPoliciesPageData = {
@@ -50,77 +48,84 @@ export type BuyingPoliciesPageQuery = GetAddressesServiceProps & {
50
48
 
51
49
  const loaderFunction = async (
52
50
  data: LoaderData<BuyingPoliciesPageQuery>
53
- ): Promise<BuyingPoliciesPageData> => {
51
+ ): Promise<AuthRouteProps<BuyingPoliciesPageData>> => {
54
52
  const { contractId, orgUnitId, search = "", page: pageString } = data.query;
55
53
 
56
54
  const page = getValidPage(pageString);
57
55
 
58
- const { cookie, userId, ...clientContext } = await getClientContext(data);
59
-
60
- if (!contractId || !orgUnitId) {
61
- return {
62
- buyingPolicies: [],
63
- total: 0,
64
- search: search ?? "",
65
- page: page ?? 1,
66
- context: {
67
- clientContext: { cookie, userId, ...clientContext },
68
- currentOrgUnit: null,
69
- currentContract: null,
70
- currentUser: null,
71
- },
72
- };
73
- }
56
+ return withAuthLoader(
57
+ data,
58
+ async ({ cookie, userId, customerId, ...clientContext }) => {
59
+ if (!contractId || !orgUnitId) {
60
+ return {
61
+ buyingPolicies: [],
62
+ total: 0,
63
+ search: search ?? "",
64
+ page: page ?? 1,
65
+ context: {
66
+ clientContext: { cookie, userId, customerId, ...clientContext },
67
+ currentOrgUnit: null,
68
+ currentContract: null,
69
+ currentUser: null,
70
+ },
71
+ budgetData: { data: [], total: 0 },
72
+ };
73
+ }
74
74
 
75
- const [currentOrgUnit, user, contract, budgetData, buyingPoliciesResponse] =
76
- await Promise.all([
77
- getOrgUnitBasicDataService({
78
- id: orgUnitId,
79
- cookie,
80
- }),
81
- getUserByIdService({ orgUnitId, userId, cookie }),
82
- getContractDetailsService({
83
- contractId,
84
- cookie,
85
- unitId: orgUnitId,
86
- }),
75
+ const [
76
+ currentOrgUnit,
77
+ user,
78
+ contract,
79
+ budgetData,
80
+ buyingPoliciesResponse,
81
+ ] = await Promise.all([
82
+ getOrgUnitBasicDataService({
83
+ id: orgUnitId,
84
+ cookie,
85
+ }),
86
+ getUserByIdService({ orgUnitId, userId, cookie }),
87
+ getContractDetailsService({
88
+ contractId,
89
+ cookie,
90
+ unitId: orgUnitId,
91
+ }),
92
+ listBudgetsService({
93
+ customerId,
94
+ cookie,
95
+ unitId: orgUnitId,
96
+ }),
97
+ getBuyingPoliciesService({
98
+ orgUnitId,
99
+ contractId,
100
+ cookie,
101
+ page,
102
+ search,
103
+ }),
104
+ ]);
87
105
 
88
- listBudgetsService({
89
- customerId: clientContext.customerId,
90
- cookie,
91
- unitId: orgUnitId,
92
- }),
106
+ const { data: buyingPolicies = [], total = 0 } = buyingPoliciesResponse;
93
107
 
94
- getBuyingPoliciesService({
95
- orgUnitId,
96
- contractId,
97
- cookie,
98
- page,
108
+ return {
109
+ buyingPolicies: search
110
+ ? buyingPolicies.filter((buyingPolicy) =>
111
+ buyingPolicy.name
112
+ .toLocaleLowerCase()
113
+ .includes(search.toLocaleLowerCase())
114
+ )
115
+ : buyingPolicies,
116
+ total,
99
117
  search,
100
- }),
101
- ]);
102
-
103
- const { data: buyingPolicies = [], total = 0 } = buyingPoliciesResponse;
104
-
105
- return {
106
- buyingPolicies: search
107
- ? buyingPolicies.filter((buyingPolicy) =>
108
- buyingPolicy.name
109
- .toLocaleLowerCase()
110
- .includes(search.toLocaleLowerCase())
111
- )
112
- : buyingPolicies,
113
- total,
114
- search,
115
- page,
116
- context: {
117
- clientContext: { cookie, userId, ...clientContext },
118
- currentOrgUnit,
119
- currentUser: user,
120
- currentContract: contract,
121
- },
122
- budgetData: budgetData ?? { data: [], total: 0 },
123
- };
118
+ page,
119
+ context: {
120
+ clientContext: { cookie, userId, customerId, ...clientContext },
121
+ currentOrgUnit,
122
+ currentUser: user,
123
+ currentContract: contract,
124
+ },
125
+ budgetData: budgetData ?? { data: [], total: 0 },
126
+ };
127
+ }
128
+ );
124
129
  };
125
130
 
126
131
  export const loader = withLoaderErrorBoundary(loaderFunction, {
@@ -132,13 +137,12 @@ const BuyingPoliciesPage = ({
132
137
  buyingPolicies,
133
138
  search,
134
139
  page,
135
- context,
136
140
  total,
137
141
  hasError,
138
142
  error,
139
143
  budgetData = { data: [], total: 0 },
140
144
  }: BuyingPoliciesPageData) => (
141
- <BuyerPortalProvider {...context}>
145
+ <>
142
146
  {hasError ? (
143
147
  <ErrorTabsLayout error={error} />
144
148
  ) : (
@@ -150,12 +154,14 @@ const BuyingPoliciesPage = ({
150
154
  budgetData={budgetData}
151
155
  />
152
156
  )}
153
- </BuyerPortalProvider>
157
+ </>
154
158
  );
155
159
 
156
- export default withErrorBoundary(BuyingPoliciesPage, {
157
- tags: {
158
- component: "BuyingPoliciesPage",
159
- errorType: "buying_policies_error",
160
- },
161
- });
160
+ export default withProviders(
161
+ withErrorBoundary(BuyingPoliciesPage, {
162
+ tags: {
163
+ component: "BuyingPoliciesPage",
164
+ errorType: "buying_policies_error",
165
+ },
166
+ })
167
+ );