@vtex/faststore-plugin-buyer-portal 1.1.92 → 1.1.94

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 (62) hide show
  1. package/cypress/constants.ts +4 -9
  2. package/cypress/integration/addresses.test.ts +39 -55
  3. package/cypress/integration/budgets.test.ts +130 -100
  4. package/cypress/integration/buying-policies.test.ts +66 -96
  5. package/cypress/integration/collections.test.ts +192 -172
  6. package/cypress/integration/credit-cards.test.ts +1 -1
  7. package/cypress/integration/locations.test.ts +39 -43
  8. package/cypress/integration/organizational-units.test.ts +70 -33
  9. package/cypress/integration/recipients.test.ts +34 -46
  10. package/cypress/integration/users.test.ts +83 -136
  11. package/cypress/shared.ts +32 -2
  12. package/cypress/support/addressHelper.tsx +17 -6
  13. package/package.json +1 -1
  14. package/public/buyer-portal-icons.svg +1 -1
  15. package/src/features/addresses/components/DeleteRecipientAddressDrawer/DeleteRecipientAddressDrawer.tsx +1 -1
  16. package/src/features/addresses/services/get-addresses-by-unit-id.service.ts +13 -1
  17. package/src/features/addresses/services/get-addresses.service.ts +15 -2
  18. package/src/features/buying-policies/services/get-buying-policies.service.ts +19 -21
  19. package/src/features/contracts/services/get-contract-details.service.ts +13 -1
  20. package/src/features/contracts/services/get-contracts-org-by-unit-id.service.ts +18 -11
  21. package/src/features/contracts/services/update-contract-status.service.ts +18 -11
  22. package/src/features/profile/layouts/ProfileLayout/profile-layout.scss +1 -0
  23. package/src/features/shared/clients/Client.ts +84 -8
  24. package/src/features/shared/components/BuyerPortalProvider/BuyerPortalProvider.tsx +4 -1
  25. package/src/features/shared/components/Error/Error.tsx +31 -0
  26. package/src/features/shared/components/Error/error.scss +71 -0
  27. package/src/features/shared/components/ErrorBoundary/ErrorBoundary.tsx +63 -0
  28. package/src/features/shared/components/ErrorBoundary/types.ts +14 -0
  29. package/src/features/shared/components/index.ts +3 -0
  30. package/src/features/shared/components/withErrorBoundary/withErrorBoundary.tsx +35 -0
  31. package/src/features/shared/layouts/BaseTabsLayout/SidebarMenu.tsx +9 -2
  32. package/src/features/shared/layouts/ContractTabsLayout/ContractTabsLayout.tsx +4 -2
  33. package/src/features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout.tsx +119 -0
  34. package/src/features/shared/layouts/ErrorTabsLayout/error-tabs-layout.scss +1 -0
  35. package/src/features/shared/utils/constants.ts +1 -1
  36. package/src/features/shared/utils/environment.ts +41 -0
  37. package/src/features/shared/utils/extractErrorMessage.ts +22 -0
  38. package/src/features/shared/utils/getHome.tsx +5 -0
  39. package/src/features/shared/utils/index.ts +2 -0
  40. package/src/features/shared/utils/withClientErrorBoundary.ts +61 -0
  41. package/src/features/shared/utils/withLoaderErrorBoundary.ts +46 -0
  42. package/src/features/users/clients/UsersClient.ts +0 -1
  43. package/src/pages/address-details.tsx +38 -11
  44. package/src/pages/addresses.tsx +35 -6
  45. package/src/pages/budgets-details.tsx +38 -8
  46. package/src/pages/budgets.tsx +33 -8
  47. package/src/pages/buying-policies.tsx +36 -12
  48. package/src/pages/buying-policy-details.tsx +38 -8
  49. package/src/pages/collections.tsx +36 -12
  50. package/src/pages/cost-centers.tsx +38 -8
  51. package/src/pages/credit-cards.tsx +38 -8
  52. package/src/pages/home.tsx +22 -5
  53. package/src/pages/org-unit-details.tsx +43 -7
  54. package/src/pages/org-units.tsx +39 -8
  55. package/src/pages/payment-methods.tsx +38 -8
  56. package/src/pages/po-numbers.tsx +38 -8
  57. package/src/pages/profile.tsx +31 -6
  58. package/src/pages/releases.tsx +33 -8
  59. package/src/pages/role-details.tsx +39 -7
  60. package/src/pages/roles.tsx +28 -7
  61. package/src/pages/user-details.tsx +39 -8
  62. package/src/pages/users.tsx +25 -7
@@ -5,11 +5,17 @@ import { ScopeCollection } from "../features/collections/types";
5
5
  import { getContractDetailsService } from "../features/contracts/services";
6
6
  import { ContractData } from "../features/contracts/types";
7
7
  import { getOrgUnitBasicDataService } from "../features/org-units/services";
8
- import { BuyerPortalProvider } from "../features/shared/components";
8
+ import {
9
+ BuyerPortalProvider,
10
+ withErrorBoundary,
11
+ } from "../features/shared/components";
12
+ import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
13
+ import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
9
14
  import {
10
15
  type ClientContext,
11
16
  getClientContext,
12
17
  getValidPage,
18
+ withLoaderErrorBoundary,
13
19
  } from "../features/shared/utils";
14
20
 
15
21
  import type { OrgUnitBasicData } from "../features/org-units/types";
@@ -26,6 +32,8 @@ export type CollectionsData = {
26
32
  currentOrgUnit: OrgUnitBasicData;
27
33
  currentContract: ContractData | null;
28
34
  };
35
+ hasError?: boolean;
36
+ error?: ErrorBoundaryProps;
29
37
  };
30
38
 
31
39
  export type CollectionsQuery = {
@@ -35,9 +43,9 @@ export type CollectionsQuery = {
35
43
  page: string;
36
44
  };
37
45
 
38
- export async function loader(
46
+ const loaderFunction = async (
39
47
  data: LoaderData<CollectionsQuery>
40
- ): Promise<CollectionsData> {
48
+ ): Promise<CollectionsData> => {
41
49
  const { contractId, orgUnitId, search = "", page: pageString } = data.query;
42
50
 
43
51
  const page = getValidPage(pageString);
@@ -89,7 +97,12 @@ export async function loader(
89
97
  currentOrgUnit,
90
98
  },
91
99
  };
92
- }
100
+ };
101
+
102
+ export const loader = withLoaderErrorBoundary(loaderFunction, {
103
+ componentName: "CollectionsPage",
104
+ redirectToError: true,
105
+ });
93
106
 
94
107
  const CollectionsPage = ({
95
108
  context,
@@ -98,16 +111,27 @@ const CollectionsPage = ({
98
111
  isContractEmpty,
99
112
  page,
100
113
  search,
114
+ hasError,
115
+ error,
101
116
  }: CollectionsData) => (
102
117
  <BuyerPortalProvider {...context}>
103
- <CollectionsLayout
104
- page={page}
105
- search={search}
106
- initialCollections={collections}
107
- drawerCollections={drawerCollections}
108
- isContractEmpty={isContractEmpty}
109
- />
118
+ {hasError ? (
119
+ <ErrorTabsLayout error={error} />
120
+ ) : (
121
+ <CollectionsLayout
122
+ page={page}
123
+ search={search}
124
+ initialCollections={collections}
125
+ drawerCollections={drawerCollections}
126
+ isContractEmpty={isContractEmpty}
127
+ />
128
+ )}
110
129
  </BuyerPortalProvider>
111
130
  );
112
131
 
113
- export default CollectionsPage;
132
+ export default withErrorBoundary(CollectionsPage, {
133
+ tags: {
134
+ component: "CollectionsPage",
135
+ errorType: "collections_error",
136
+ },
137
+ });
@@ -1,8 +1,17 @@
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 { BuyerPortalProvider } from "../features/shared/components";
5
- import { ClientContext, getClientContext } from "../features/shared/utils";
4
+ import {
5
+ BuyerPortalProvider,
6
+ withErrorBoundary,
7
+ } from "../features/shared/components";
8
+ import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
9
+ import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
10
+ import {
11
+ ClientContext,
12
+ getClientContext,
13
+ withLoaderErrorBoundary,
14
+ } from "../features/shared/utils";
6
15
  import { getUserByIdService } from "../features/users/services";
7
16
 
8
17
  import type { ContractData } from "../features/contracts/types";
@@ -19,6 +28,8 @@ export type CostCentersPageData = {
19
28
  currentUser: UserData | null;
20
29
  search: string;
21
30
  };
31
+ hasError?: boolean;
32
+ error?: ErrorBoundaryProps;
22
33
  };
23
34
 
24
35
  type OrgUnitsPageQuery = {
@@ -27,9 +38,9 @@ type OrgUnitsPageQuery = {
27
38
  search?: string;
28
39
  };
29
40
 
30
- export async function loader(
41
+ const loaderFunction = async (
31
42
  data: LoaderData<OrgUnitsPageQuery>
32
- ): Promise<CostCentersPageData> {
43
+ ): Promise<CostCentersPageData> => {
33
44
  const { customerId, cookie, userId, ...clientContext } =
34
45
  await getClientContext(data);
35
46
 
@@ -51,14 +62,33 @@ export async function loader(
51
62
  currentUser: user,
52
63
  },
53
64
  };
54
- }
65
+ };
66
+
67
+ export const loader = withLoaderErrorBoundary(loaderFunction, {
68
+ componentName: "CostCentersPage",
69
+ redirectToError: true,
70
+ });
55
71
 
56
- const CostCentersPage = ({ data, context }: CostCentersPageData) => {
72
+ const CostCentersPage = ({
73
+ data,
74
+ context,
75
+ hasError,
76
+ error,
77
+ }: CostCentersPageData) => {
57
78
  return (
58
79
  <BuyerPortalProvider {...context}>
59
- <CustomFieldsLayout data={data} customFieldsLabel="Cost Center" />
80
+ {hasError ? (
81
+ <ErrorTabsLayout error={error} />
82
+ ) : (
83
+ <CustomFieldsLayout data={data} customFieldsLabel="Cost Center" />
84
+ )}
60
85
  </BuyerPortalProvider>
61
86
  );
62
87
  };
63
88
 
64
- export default CostCentersPage;
89
+ export default withErrorBoundary(CostCentersPage, {
90
+ tags: {
91
+ component: "CostCentersPage",
92
+ errorType: "cost_centers_error",
93
+ },
94
+ });
@@ -3,8 +3,17 @@ import { CreditCardLayout } from "../features/credit-cards/layouts";
3
3
  import { getCreditCardsListService } from "../features/credit-cards/services";
4
4
  import { CreditCardData } from "../features/credit-cards/types";
5
5
  import { getOrgUnitBasicDataService } from "../features/org-units/services";
6
- import { BuyerPortalProvider } from "../features/shared/components";
7
- import { type ClientContext, getClientContext } from "../features/shared/utils";
6
+ import {
7
+ BuyerPortalProvider,
8
+ withErrorBoundary,
9
+ } from "../features/shared/components";
10
+ import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
11
+ import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
12
+ import {
13
+ type ClientContext,
14
+ getClientContext,
15
+ withLoaderErrorBoundary,
16
+ } from "../features/shared/utils";
8
17
  import { getUserByIdService } from "../features/users/services";
9
18
 
10
19
  import type { ContractData } from "../features/contracts/types";
@@ -20,6 +29,8 @@ export type CreditCardPageData = {
20
29
  currentOrgUnit: OrgUnitBasicData | null;
21
30
  currentUser: UserData | null;
22
31
  };
32
+ hasError?: boolean;
33
+ error?: ErrorBoundaryProps;
23
34
  };
24
35
 
25
36
  export type CreditCardPageQuery = {
@@ -27,9 +38,9 @@ export type CreditCardPageQuery = {
27
38
  contractId: string;
28
39
  };
29
40
 
30
- export async function loader(
41
+ const loaderFunction = async (
31
42
  data: LoaderData<CreditCardPageQuery>
32
- ): Promise<CreditCardPageData> {
43
+ ): Promise<CreditCardPageData> => {
33
44
  const { contractId, orgUnitId } = data.query;
34
45
 
35
46
  const { cookie, userId, ...clientContext } = await getClientContext(data);
@@ -61,12 +72,31 @@ export async function loader(
61
72
  currentContract: contract,
62
73
  },
63
74
  };
64
- }
75
+ };
76
+
77
+ export const loader = withLoaderErrorBoundary(loaderFunction, {
78
+ componentName: "CreditCardsPage",
79
+ redirectToError: true,
80
+ });
65
81
 
66
- const CreditCardsPage = ({ data, context }: CreditCardPageData) => (
82
+ const CreditCardsPage = ({
83
+ data,
84
+ context,
85
+ hasError,
86
+ error,
87
+ }: CreditCardPageData) => (
67
88
  <BuyerPortalProvider {...context}>
68
- <CreditCardLayout data={data} />
89
+ {hasError ? (
90
+ <ErrorTabsLayout error={error} />
91
+ ) : (
92
+ <CreditCardLayout data={data} />
93
+ )}
69
94
  </BuyerPortalProvider>
70
95
  );
71
96
 
72
- export default CreditCardsPage;
97
+ export default withErrorBoundary(CreditCardsPage, {
98
+ tags: {
99
+ component: "CreditCardsPage",
100
+ errorType: "credit_cards_error",
101
+ },
102
+ });
@@ -1,22 +1,29 @@
1
1
  import { useRouter } from "next/router";
2
2
 
3
3
  import { getOrgUnitByUserIdService } from "../features/org-units/services";
4
- import { getClientContext } from "../features/shared/utils";
4
+ import { withErrorBoundary } from "../features/shared/components";
5
+ import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
6
+ import {
7
+ getClientContext,
8
+ withLoaderErrorBoundary,
9
+ } from "../features/shared/utils";
5
10
  import { buyerPortalRoutes } from "../features/shared/utils/buyerPortalRoutes";
6
11
 
7
12
  import type { LoaderData } from "../features/shared/types";
8
13
 
9
14
  export type HomePageData = {
10
15
  redirected: boolean;
16
+ hasError?: boolean;
17
+ error?: ErrorBoundaryProps;
11
18
  };
12
19
 
13
20
  type HomePageQuery = {
14
21
  contractMode?: string[];
15
22
  };
16
23
 
17
- export async function loader(
24
+ const loaderFunction = async (
18
25
  data: LoaderData<HomePageQuery>
19
- ): Promise<HomePageData> {
26
+ ): Promise<HomePageData> => {
20
27
  const { userId, cookie } = await getClientContext(data);
21
28
 
22
29
  const userOrgUnit = await getOrgUnitByUserIdService({ userId, cookie });
@@ -38,11 +45,21 @@ export async function loader(
38
45
  return {
39
46
  redirected: true,
40
47
  };
41
- }
48
+ };
49
+
50
+ export const loader = withLoaderErrorBoundary(loaderFunction, {
51
+ componentName: "HomePage",
52
+ redirectToError: true,
53
+ });
42
54
 
43
55
  const HomePage = () => {
44
56
  useRouter().reload();
45
57
  return null;
46
58
  };
47
59
 
48
- export default HomePage;
60
+ export default withErrorBoundary(HomePage, {
61
+ tags: {
62
+ component: "HomePage",
63
+ errorType: "home_error",
64
+ },
65
+ });
@@ -1,8 +1,16 @@
1
1
  import { getContractsByOrgUnitIdService } from "../features/contracts/services";
2
2
  import { OrgUnitsDetailsLayout } from "../features/org-units/layouts";
3
3
  import { getOrgUnitBasicDataService } from "../features/org-units/services";
4
- import { BuyerPortalProvider } from "../features/shared/components";
5
- import { type ClientContext, getClientContext } from "../features/shared/utils";
4
+ import {
5
+ BuyerPortalProvider,
6
+ withErrorBoundary,
7
+ } from "../features/shared/components";
8
+ import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
9
+ import {
10
+ type ClientContext,
11
+ getClientContext,
12
+ withLoaderErrorBoundary,
13
+ } from "../features/shared/utils";
6
14
  import { getUserByIdService } from "../features/users/services";
7
15
 
8
16
  import type { ContractData } from "../features/contracts/types";
@@ -17,15 +25,27 @@ export type OrgUnitDetailsPageData = {
17
25
  user: UserData | null;
18
26
  };
19
27
  clientContext: ClientContext;
28
+ hasError?: boolean;
29
+ error?: {
30
+ error: {
31
+ message: string;
32
+ name: string;
33
+ stack?: string;
34
+ };
35
+ tags: {
36
+ component: string;
37
+ errorType: string;
38
+ };
39
+ };
20
40
  };
21
41
 
22
42
  type OrgUnitDetailsPageQuery = {
23
43
  orgUnitId: string;
24
44
  };
25
45
 
26
- export async function loader(
46
+ const loaderFunction = async (
27
47
  data: LoaderData<OrgUnitDetailsPageQuery>
28
- ): Promise<OrgUnitDetailsPageData> {
48
+ ): Promise<OrgUnitDetailsPageData> => {
29
49
  const { orgUnitId } = data.query;
30
50
 
31
51
  const { cookie, userId, ...clientContext } = await getClientContext(data);
@@ -50,17 +70,33 @@ export async function loader(
50
70
  },
51
71
  clientContext: { cookie, userId, ...clientContext },
52
72
  };
53
- }
73
+ };
74
+
75
+ export const loader = withLoaderErrorBoundary(loaderFunction, {
76
+ componentName: "OrgUnitDetailsPage",
77
+ redirectToError: true,
78
+ });
54
79
 
55
80
  const OrgUnitDetailsPage = ({
56
81
  data,
57
82
  clientContext,
83
+ hasError,
84
+ error,
58
85
  }: OrgUnitDetailsPageData) => {
59
86
  return (
60
87
  <BuyerPortalProvider clientContext={clientContext}>
61
- <OrgUnitsDetailsLayout data={data} />
88
+ {hasError ? (
89
+ <ErrorTabsLayout error={error} />
90
+ ) : (
91
+ <OrgUnitsDetailsLayout data={data} />
92
+ )}
62
93
  </BuyerPortalProvider>
63
94
  );
64
95
  };
65
96
 
66
- export default OrgUnitDetailsPage;
97
+ export default withErrorBoundary(OrgUnitDetailsPage, {
98
+ tags: {
99
+ component: "OrgUnitDetailsPage",
100
+ errorType: "org_unit_details_error",
101
+ },
102
+ });
@@ -5,8 +5,17 @@ import {
5
5
  getOrgUnitByIdService,
6
6
  searchOrgUnitsByNameService,
7
7
  } from "../features/org-units/services";
8
- import { BuyerPortalProvider } from "../features/shared/components";
9
- import { type ClientContext, getClientContext } from "../features/shared/utils";
8
+ import {
9
+ BuyerPortalProvider,
10
+ withErrorBoundary,
11
+ } from "../features/shared/components";
12
+ import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
13
+ import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
14
+ import {
15
+ type ClientContext,
16
+ getClientContext,
17
+ withLoaderErrorBoundary,
18
+ } from "../features/shared/utils";
10
19
  import { getUserByIdService } from "../features/users/services";
11
20
 
12
21
  import type {
@@ -24,6 +33,8 @@ export type OrgUnitsPageData = {
24
33
  currentOrgUnit: OrgUnitBasicData | null;
25
34
  currentUser: UserData | null;
26
35
  };
36
+ hasError?: boolean;
37
+ error?: ErrorBoundaryProps;
27
38
  };
28
39
 
29
40
  type OrgUnitsPageQuery = {
@@ -31,9 +42,9 @@ type OrgUnitsPageQuery = {
31
42
  search?: string;
32
43
  };
33
44
 
34
- export async function loader(
45
+ const loaderFunction = async (
35
46
  data: LoaderData<OrgUnitsPageQuery>
36
- ): Promise<OrgUnitsPageData> {
47
+ ): Promise<OrgUnitsPageData> => {
37
48
  const { cookie, customerId, userId, ...restClientContext } =
38
49
  await getClientContext(data);
39
50
 
@@ -107,14 +118,34 @@ export async function loader(
107
118
  currentUser: user,
108
119
  },
109
120
  };
110
- }
121
+ };
111
122
 
112
- const OrgUnitsPage = ({ data, search, context }: OrgUnitsPageData) => {
123
+ export const loader = withLoaderErrorBoundary(loaderFunction, {
124
+ componentName: "OrgUnitsPage",
125
+ redirectToError: true,
126
+ });
127
+
128
+ const OrgUnitsPage = ({
129
+ data,
130
+ search,
131
+ context,
132
+ hasError,
133
+ error,
134
+ }: OrgUnitsPageData) => {
113
135
  return (
114
136
  <BuyerPortalProvider {...context}>
115
- <OrgUnitsLayout data={data} search={search} />
137
+ {hasError ? (
138
+ <ErrorTabsLayout error={error} />
139
+ ) : (
140
+ <OrgUnitsLayout data={data} search={search} />
141
+ )}
116
142
  </BuyerPortalProvider>
117
143
  );
118
144
  };
119
145
 
120
- export default OrgUnitsPage;
146
+ export default withErrorBoundary(OrgUnitsPage, {
147
+ tags: {
148
+ component: "OrgUnitsPage",
149
+ errorType: "org_units_error",
150
+ },
151
+ });
@@ -5,8 +5,17 @@ import {
5
5
  getPaymentMethodsByUnitIdService,
6
6
  GetPaymentMethodsByUnitIdServiceProps,
7
7
  } from "../features/payment-methods/services";
8
- import { BuyerPortalProvider } from "../features/shared/components";
9
- import { type ClientContext, getClientContext } from "../features/shared/utils";
8
+ import {
9
+ BuyerPortalProvider,
10
+ withErrorBoundary,
11
+ } from "../features/shared/components";
12
+ import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
13
+ import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
14
+ import {
15
+ type ClientContext,
16
+ getClientContext,
17
+ withLoaderErrorBoundary,
18
+ } from "../features/shared/utils";
10
19
  import { getUserByIdService } from "../features/users/services";
11
20
 
12
21
  import type { ContractData } from "../features/contracts/types";
@@ -24,6 +33,8 @@ export type PaymentMethodsPageData = {
24
33
  currentOrgUnit: OrgUnitBasicData | null;
25
34
  currentUser: UserData | null;
26
35
  };
36
+ hasError?: boolean;
37
+ error?: ErrorBoundaryProps;
27
38
  };
28
39
 
29
40
  export type PaymentMethodsPageQuery = GetPaymentMethodsByUnitIdServiceProps & {
@@ -31,9 +42,9 @@ export type PaymentMethodsPageQuery = GetPaymentMethodsByUnitIdServiceProps & {
31
42
  contractId: string;
32
43
  };
33
44
 
34
- export async function loader(
45
+ const loaderFunction = async (
35
46
  data: LoaderData<PaymentMethodsPageQuery>
36
- ): Promise<PaymentMethodsPageData> {
47
+ ): Promise<PaymentMethodsPageData> => {
37
48
  const { contractId, orgUnitId, search } = data.query;
38
49
 
39
50
  const { cookie, userId, ...clientContext } = await getClientContext(data);
@@ -67,12 +78,31 @@ export async function loader(
67
78
  currentContract: contract,
68
79
  },
69
80
  };
70
- }
81
+ };
82
+
83
+ export const loader = withLoaderErrorBoundary(loaderFunction, {
84
+ componentName: "PaymentMethodsPage",
85
+ redirectToError: true,
86
+ });
71
87
 
72
- const PaymentMethodsPage = ({ data, context }: PaymentMethodsPageData) => (
88
+ const PaymentMethodsPage = ({
89
+ data,
90
+ context,
91
+ hasError,
92
+ error,
93
+ }: PaymentMethodsPageData) => (
73
94
  <BuyerPortalProvider {...context}>
74
- <PaymentMethodsLayout data={data} />
95
+ {hasError ? (
96
+ <ErrorTabsLayout error={error} />
97
+ ) : (
98
+ <PaymentMethodsLayout data={data} />
99
+ )}
75
100
  </BuyerPortalProvider>
76
101
  );
77
102
 
78
- export default PaymentMethodsPage;
103
+ export default withErrorBoundary(PaymentMethodsPage, {
104
+ tags: {
105
+ component: "PaymentMethodsPage",
106
+ errorType: "payment_methods_error",
107
+ },
108
+ });
@@ -1,8 +1,17 @@
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 { BuyerPortalProvider } from "../features/shared/components";
5
- import { ClientContext, getClientContext } from "../features/shared/utils";
4
+ import {
5
+ BuyerPortalProvider,
6
+ withErrorBoundary,
7
+ } from "../features/shared/components";
8
+ import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
9
+ import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
10
+ import {
11
+ ClientContext,
12
+ getClientContext,
13
+ withLoaderErrorBoundary,
14
+ } from "../features/shared/utils";
6
15
  import { getUserByIdService } from "../features/users/services";
7
16
 
8
17
  import type { ContractData } from "../features/contracts/types";
@@ -19,6 +28,8 @@ export type PONumbersPageData = {
19
28
  currentUser: UserData | null;
20
29
  search: string;
21
30
  };
31
+ hasError?: boolean;
32
+ error?: ErrorBoundaryProps;
22
33
  };
23
34
 
24
35
  type OrgUnitsPageQuery = {
@@ -27,9 +38,9 @@ type OrgUnitsPageQuery = {
27
38
  search?: string;
28
39
  };
29
40
 
30
- export async function loader(
41
+ const loaderFunction = async (
31
42
  data: LoaderData<OrgUnitsPageQuery>
32
- ): Promise<PONumbersPageData> {
43
+ ): Promise<PONumbersPageData> => {
33
44
  const { customerId, cookie, userId, ...clientContext } =
34
45
  await getClientContext(data);
35
46
 
@@ -58,14 +69,33 @@ export async function loader(
58
69
  currentUser: user,
59
70
  },
60
71
  };
61
- }
72
+ };
73
+
74
+ export const loader = withLoaderErrorBoundary(loaderFunction, {
75
+ componentName: "PONumbersPage",
76
+ redirectToError: true,
77
+ });
62
78
 
63
- const PONumbersPage = ({ data, context }: PONumbersPageData) => {
79
+ const PONumbersPage = ({
80
+ data,
81
+ context,
82
+ hasError,
83
+ error,
84
+ }: PONumbersPageData) => {
64
85
  return (
65
86
  <BuyerPortalProvider {...context}>
66
- <CustomFieldsLayout data={data} customFieldsLabel="PO Number" />
87
+ {hasError ? (
88
+ <ErrorTabsLayout error={error} />
89
+ ) : (
90
+ <CustomFieldsLayout data={data} customFieldsLabel="PO Number" />
91
+ )}
67
92
  </BuyerPortalProvider>
68
93
  );
69
94
  };
70
95
 
71
- export default PONumbersPage;
96
+ export default withErrorBoundary(PONumbersPage, {
97
+ tags: {
98
+ component: "PONumbersPage",
99
+ errorType: "po_numbers_error",
100
+ },
101
+ });
@@ -1,8 +1,17 @@
1
1
  import { getContractDetailsService } from "../features/contracts/services";
2
2
  import { getOrgUnitBasicDataService } from "../features/org-units/services";
3
3
  import { ProfileLayout } from "../features/profile/layouts";
4
- import { BuyerPortalProvider } from "../features/shared/components";
5
- import { type ClientContext, getClientContext } from "../features/shared/utils";
4
+ import {
5
+ BuyerPortalProvider,
6
+ withErrorBoundary,
7
+ } from "../features/shared/components";
8
+ import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
9
+ import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
10
+ import {
11
+ type ClientContext,
12
+ getClientContext,
13
+ withLoaderErrorBoundary,
14
+ } from "../features/shared/utils";
6
15
  import { getUserByIdService } from "../features/users/services";
7
16
 
8
17
  import type { ContractData } from "../features/contracts/types";
@@ -18,6 +27,8 @@ export type ProfilePageData = {
18
27
  currentContract: ContractData | null;
19
28
  currentUser: UserData | null;
20
29
  };
30
+ hasError?: boolean;
31
+ error?: ErrorBoundaryProps;
21
32
  };
22
33
 
23
34
  export type ProfilePageQuery = {
@@ -25,7 +36,7 @@ export type ProfilePageQuery = {
25
36
  orgUnitId: string;
26
37
  };
27
38
 
28
- export async function loader(
39
+ export async function loaderFunction(
29
40
  data: LoaderData<ProfilePageQuery>
30
41
  ): Promise<ProfilePageData> {
31
42
  const { customerId, cookie, userId, ...clientContext } =
@@ -57,10 +68,24 @@ export async function loader(
57
68
  };
58
69
  }
59
70
 
60
- const ContractsPage = ({ data, context }: ProfilePageData) => (
71
+ export const loader = withLoaderErrorBoundary(loaderFunction, {
72
+ componentName: "ProfilePage",
73
+ redirectToError: true,
74
+ });
75
+
76
+ const ProfilePage = ({ data, context, hasError, error }: ProfilePageData) => (
61
77
  <BuyerPortalProvider {...context}>
62
- <ProfileLayout data={data} />
78
+ {hasError ? (
79
+ <ErrorTabsLayout error={error} />
80
+ ) : (
81
+ <ProfileLayout data={data} />
82
+ )}
63
83
  </BuyerPortalProvider>
64
84
  );
65
85
 
66
- export default ContractsPage;
86
+ export default withErrorBoundary(ProfilePage, {
87
+ tags: {
88
+ component: "ProfilePage",
89
+ errorType: "profile_error",
90
+ },
91
+ });