@vtex/faststore-plugin-buyer-portal 1.1.92 → 1.1.93
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/public/buyer-portal-icons.svg +1 -1
- package/src/features/addresses/services/get-addresses-by-unit-id.service.ts +13 -1
- package/src/features/addresses/services/get-addresses.service.ts +15 -2
- package/src/features/buying-policies/services/get-buying-policies.service.ts +19 -21
- package/src/features/contracts/services/get-contract-details.service.ts +13 -1
- package/src/features/contracts/services/get-contracts-org-by-unit-id.service.ts +18 -11
- package/src/features/contracts/services/update-contract-status.service.ts +18 -11
- package/src/features/profile/layouts/ProfileLayout/profile-layout.scss +1 -0
- package/src/features/shared/clients/Client.ts +84 -8
- package/src/features/shared/components/BuyerPortalProvider/BuyerPortalProvider.tsx +4 -1
- package/src/features/shared/components/Error/Error.tsx +31 -0
- package/src/features/shared/components/Error/error.scss +71 -0
- package/src/features/shared/components/ErrorBoundary/ErrorBoundary.tsx +63 -0
- package/src/features/shared/components/ErrorBoundary/types.ts +14 -0
- package/src/features/shared/components/index.ts +3 -0
- package/src/features/shared/components/withErrorBoundary/withErrorBoundary.tsx +35 -0
- package/src/features/shared/layouts/BaseTabsLayout/SidebarMenu.tsx +9 -2
- package/src/features/shared/layouts/ContractTabsLayout/ContractTabsLayout.tsx +4 -2
- package/src/features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout.tsx +119 -0
- package/src/features/shared/layouts/ErrorTabsLayout/error-tabs-layout.scss +1 -0
- package/src/features/shared/utils/environment.ts +41 -0
- package/src/features/shared/utils/extractErrorMessage.ts +22 -0
- package/src/features/shared/utils/getHome.tsx +5 -0
- package/src/features/shared/utils/index.ts +2 -0
- package/src/features/shared/utils/withClientErrorBoundary.ts +61 -0
- package/src/features/shared/utils/withLoaderErrorBoundary.ts +46 -0
- package/src/features/users/clients/UsersClient.ts +0 -1
- package/src/pages/address-details.tsx +38 -11
- package/src/pages/addresses.tsx +35 -6
- package/src/pages/budgets-details.tsx +38 -8
- package/src/pages/budgets.tsx +33 -8
- package/src/pages/buying-policies.tsx +36 -12
- package/src/pages/buying-policy-details.tsx +38 -8
- package/src/pages/collections.tsx +36 -12
- package/src/pages/cost-centers.tsx +38 -8
- package/src/pages/credit-cards.tsx +38 -8
- package/src/pages/home.tsx +22 -5
- package/src/pages/org-unit-details.tsx +43 -7
- package/src/pages/org-units.tsx +39 -8
- package/src/pages/payment-methods.tsx +38 -8
- package/src/pages/po-numbers.tsx +38 -8
- package/src/pages/profile.tsx +31 -6
- package/src/pages/releases.tsx +33 -8
- package/src/pages/role-details.tsx +39 -7
- package/src/pages/roles.tsx +28 -7
- package/src/pages/user-details.tsx +39 -8
- package/src/pages/users.tsx +25 -7
|
@@ -5,8 +5,17 @@ import {
|
|
|
5
5
|
getPaymentMethodsByUnitIdService,
|
|
6
6
|
GetPaymentMethodsByUnitIdServiceProps,
|
|
7
7
|
} from "../features/payment-methods/services";
|
|
8
|
-
import {
|
|
9
|
-
|
|
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
|
-
|
|
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 = ({
|
|
88
|
+
const PaymentMethodsPage = ({
|
|
89
|
+
data,
|
|
90
|
+
context,
|
|
91
|
+
hasError,
|
|
92
|
+
error,
|
|
93
|
+
}: PaymentMethodsPageData) => (
|
|
73
94
|
<BuyerPortalProvider {...context}>
|
|
74
|
-
|
|
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
|
+
});
|
package/src/pages/po-numbers.tsx
CHANGED
|
@@ -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 {
|
|
5
|
-
|
|
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
|
-
|
|
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 = ({
|
|
79
|
+
const PONumbersPage = ({
|
|
80
|
+
data,
|
|
81
|
+
context,
|
|
82
|
+
hasError,
|
|
83
|
+
error,
|
|
84
|
+
}: PONumbersPageData) => {
|
|
64
85
|
return (
|
|
65
86
|
<BuyerPortalProvider {...context}>
|
|
66
|
-
|
|
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
|
+
});
|
package/src/pages/profile.tsx
CHANGED
|
@@ -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 {
|
|
5
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
78
|
+
{hasError ? (
|
|
79
|
+
<ErrorTabsLayout error={error} />
|
|
80
|
+
) : (
|
|
81
|
+
<ProfileLayout data={data} />
|
|
82
|
+
)}
|
|
63
83
|
</BuyerPortalProvider>
|
|
64
84
|
);
|
|
65
85
|
|
|
66
|
-
export default
|
|
86
|
+
export default withErrorBoundary(ProfilePage, {
|
|
87
|
+
tags: {
|
|
88
|
+
component: "ProfilePage",
|
|
89
|
+
errorType: "profile_error",
|
|
90
|
+
},
|
|
91
|
+
});
|
package/src/pages/releases.tsx
CHANGED
|
@@ -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 {
|
|
5
|
-
|
|
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 ReleasesPageData = {
|
|
|
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
|
-
|
|
41
|
+
const loaderFunction = async (
|
|
31
42
|
data: LoaderData<OrgUnitsPageQuery>
|
|
32
|
-
): Promise<ReleasesPageData> {
|
|
43
|
+
): Promise<ReleasesPageData> => {
|
|
33
44
|
const { customerId, cookie, userId, ...clientContext } =
|
|
34
45
|
await getClientContext(data);
|
|
35
46
|
|
|
@@ -58,14 +69,28 @@ export async function loader(
|
|
|
58
69
|
currentUser: user,
|
|
59
70
|
},
|
|
60
71
|
};
|
|
61
|
-
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
75
|
+
componentName: "ReleasesPage",
|
|
76
|
+
redirectToError: true,
|
|
77
|
+
});
|
|
62
78
|
|
|
63
|
-
const ReleasesPage = ({ data, context }: ReleasesPageData) => {
|
|
79
|
+
const ReleasesPage = ({ data, context, hasError, error }: ReleasesPageData) => {
|
|
64
80
|
return (
|
|
65
81
|
<BuyerPortalProvider {...context}>
|
|
66
|
-
|
|
82
|
+
{hasError ? (
|
|
83
|
+
<ErrorTabsLayout error={error} />
|
|
84
|
+
) : (
|
|
85
|
+
<CustomFieldsLayout data={data} customFieldsLabel="Release" />
|
|
86
|
+
)}
|
|
67
87
|
</BuyerPortalProvider>
|
|
68
88
|
);
|
|
69
89
|
};
|
|
70
90
|
|
|
71
|
-
export default ReleasesPage
|
|
91
|
+
export default withErrorBoundary(ReleasesPage, {
|
|
92
|
+
tags: {
|
|
93
|
+
component: "ReleasesPage",
|
|
94
|
+
errorType: "releases_error",
|
|
95
|
+
},
|
|
96
|
+
});
|
|
@@ -2,8 +2,17 @@ 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
|
-
|
|
5
|
+
import {
|
|
6
|
+
BuyerPortalProvider,
|
|
7
|
+
withErrorBoundary,
|
|
8
|
+
} from "../features/shared/components";
|
|
9
|
+
import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
|
|
10
|
+
import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
|
|
11
|
+
import {
|
|
12
|
+
type ClientContext,
|
|
13
|
+
getClientContext,
|
|
14
|
+
withLoaderErrorBoundary,
|
|
15
|
+
} from "../features/shared/utils";
|
|
7
16
|
import { getUserByIdService } from "../features/users/services";
|
|
8
17
|
|
|
9
18
|
import type { OrgUnitBasicData } from "../features/org-units/types";
|
|
@@ -20,9 +29,13 @@ export type RoleDetailsPageData = {
|
|
|
20
29
|
currentOrgUnit: OrgUnitBasicData | null;
|
|
21
30
|
currentUser: UserData | null;
|
|
22
31
|
};
|
|
32
|
+
hasError?: boolean;
|
|
33
|
+
error?: ErrorBoundaryProps;
|
|
23
34
|
};
|
|
24
35
|
|
|
25
|
-
|
|
36
|
+
const loaderFunction = async (
|
|
37
|
+
data: LoaderData
|
|
38
|
+
): Promise<RoleDetailsPageData> => {
|
|
26
39
|
const { cookie, userId, ...clientContext } = await getClientContext(data);
|
|
27
40
|
|
|
28
41
|
const { orgUnitId, roleName } = data.query;
|
|
@@ -74,12 +87,31 @@ export async function loader(data: LoaderData): Promise<RoleDetailsPageData> {
|
|
|
74
87
|
currentUser: user,
|
|
75
88
|
},
|
|
76
89
|
};
|
|
77
|
-
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
93
|
+
componentName: "RoleDetailsPage",
|
|
94
|
+
redirectToError: true,
|
|
95
|
+
});
|
|
78
96
|
|
|
79
|
-
const
|
|
97
|
+
const RoleDetailsPage = ({
|
|
98
|
+
data,
|
|
99
|
+
context,
|
|
100
|
+
hasError,
|
|
101
|
+
error,
|
|
102
|
+
}: RoleDetailsPageData) => (
|
|
80
103
|
<BuyerPortalProvider {...context}>
|
|
81
|
-
|
|
104
|
+
{hasError ? (
|
|
105
|
+
<ErrorTabsLayout error={error} />
|
|
106
|
+
) : (
|
|
107
|
+
<RoleDetailsLayout data={data} />
|
|
108
|
+
)}
|
|
82
109
|
</BuyerPortalProvider>
|
|
83
110
|
);
|
|
84
111
|
|
|
85
|
-
export default
|
|
112
|
+
export default withErrorBoundary(RoleDetailsPage, {
|
|
113
|
+
tags: {
|
|
114
|
+
component: "RoleDetailsPage",
|
|
115
|
+
errorType: "role_details_error",
|
|
116
|
+
},
|
|
117
|
+
});
|
package/src/pages/roles.tsx
CHANGED
|
@@ -2,8 +2,17 @@ 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
|
-
|
|
5
|
+
import {
|
|
6
|
+
BuyerPortalProvider,
|
|
7
|
+
withErrorBoundary,
|
|
8
|
+
} from "../features/shared/components";
|
|
9
|
+
import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
|
|
10
|
+
import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
|
|
11
|
+
import {
|
|
12
|
+
type ClientContext,
|
|
13
|
+
getClientContext,
|
|
14
|
+
withLoaderErrorBoundary,
|
|
15
|
+
} from "../features/shared/utils";
|
|
7
16
|
import { getUserByIdService } from "../features/users/services";
|
|
8
17
|
|
|
9
18
|
import type { OrgUnitBasicData } from "../features/org-units/types";
|
|
@@ -19,9 +28,11 @@ export type RolesPageData = {
|
|
|
19
28
|
currentOrgUnit: OrgUnitBasicData | null;
|
|
20
29
|
currentUser: UserData | null;
|
|
21
30
|
};
|
|
31
|
+
hasError?: boolean;
|
|
32
|
+
error?: ErrorBoundaryProps;
|
|
22
33
|
};
|
|
23
34
|
|
|
24
|
-
|
|
35
|
+
const loaderFunction = async (data: LoaderData): Promise<RolesPageData> => {
|
|
25
36
|
const { cookie, userId, ...clientContext } = await getClientContext(data);
|
|
26
37
|
const { orgUnitId } = data.query;
|
|
27
38
|
|
|
@@ -48,12 +59,22 @@ export async function loader(data: LoaderData): Promise<RolesPageData> {
|
|
|
48
59
|
currentUser: user,
|
|
49
60
|
},
|
|
50
61
|
};
|
|
51
|
-
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
65
|
+
componentName: "RolesPage",
|
|
66
|
+
redirectToError: true,
|
|
67
|
+
});
|
|
52
68
|
|
|
53
|
-
const
|
|
69
|
+
const RolesPage = ({ data, context, hasError, error }: RolesPageData) => (
|
|
54
70
|
<BuyerPortalProvider {...context}>
|
|
55
|
-
<RolesLayout data={data} />
|
|
71
|
+
{hasError ? <ErrorTabsLayout error={error} /> : <RolesLayout data={data} />}
|
|
56
72
|
</BuyerPortalProvider>
|
|
57
73
|
);
|
|
58
74
|
|
|
59
|
-
export default
|
|
75
|
+
export default withErrorBoundary(RolesPage, {
|
|
76
|
+
tags: {
|
|
77
|
+
component: "RolesPage",
|
|
78
|
+
errorType: "roles_error",
|
|
79
|
+
},
|
|
80
|
+
});
|
|
@@ -3,8 +3,17 @@ import {
|
|
|
3
3
|
getOrgUnitByUserIdService,
|
|
4
4
|
} from "../features/org-units/services";
|
|
5
5
|
import { getRolesIdsService } from "../features/roles/services";
|
|
6
|
-
import {
|
|
7
|
-
|
|
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 { UserDetailsLayout } from "../features/users/layouts";
|
|
9
18
|
import { getUserByIdService } from "../features/users/services/get-user-by-id.service";
|
|
10
19
|
|
|
@@ -29,11 +38,13 @@ export type UserDetailsPageData = {
|
|
|
29
38
|
currentOrgUnit: OrgUnitBasicData | null;
|
|
30
39
|
currentUser: UserData | null;
|
|
31
40
|
};
|
|
41
|
+
hasError?: boolean;
|
|
42
|
+
error?: ErrorBoundaryProps;
|
|
32
43
|
};
|
|
33
44
|
|
|
34
|
-
|
|
45
|
+
const loaderFunction = async (
|
|
35
46
|
data: LoaderData<UserDetailsPageQuery>
|
|
36
|
-
): Promise<UserDetailsPageData> {
|
|
47
|
+
): Promise<UserDetailsPageData> => {
|
|
37
48
|
const { cookie, customerId, ...clientContext } = await getClientContext(data);
|
|
38
49
|
|
|
39
50
|
const { userId, orgUnitId } = data.query;
|
|
@@ -76,11 +87,31 @@ export async function loader(
|
|
|
76
87
|
currentUser: user,
|
|
77
88
|
},
|
|
78
89
|
};
|
|
79
|
-
}
|
|
90
|
+
};
|
|
80
91
|
|
|
81
|
-
const
|
|
92
|
+
export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
93
|
+
componentName: "UserDetailsPage",
|
|
94
|
+
redirectToError: true,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const UserDetailsPage = ({
|
|
98
|
+
data,
|
|
99
|
+
context,
|
|
100
|
+
hasError,
|
|
101
|
+
error,
|
|
102
|
+
}: UserDetailsPageData) => (
|
|
82
103
|
<BuyerPortalProvider {...context}>
|
|
83
|
-
|
|
104
|
+
{hasError ? (
|
|
105
|
+
<ErrorTabsLayout error={error} />
|
|
106
|
+
) : (
|
|
107
|
+
<UserDetailsLayout data={data} />
|
|
108
|
+
)}
|
|
84
109
|
</BuyerPortalProvider>
|
|
85
110
|
);
|
|
86
|
-
|
|
111
|
+
|
|
112
|
+
export default withErrorBoundary(UserDetailsPage, {
|
|
113
|
+
tags: {
|
|
114
|
+
component: "UserDetailsPage",
|
|
115
|
+
errorType: "user_details_error",
|
|
116
|
+
},
|
|
117
|
+
});
|
package/src/pages/users.tsx
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { getOrgUnitBasicDataService } from "../features/org-units/services";
|
|
2
2
|
import { getRolesIdsService } from "../features/roles/services";
|
|
3
3
|
import { RoleData } from "../features/roles/types";
|
|
4
|
-
import {
|
|
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";
|
|
5
10
|
import {
|
|
6
11
|
type ClientContext,
|
|
7
12
|
getClientContext,
|
|
8
13
|
getValidPage,
|
|
14
|
+
withLoaderErrorBoundary,
|
|
9
15
|
} from "../features/shared/utils";
|
|
10
16
|
import { UsersLayout } from "../features/users/layouts";
|
|
11
17
|
import {
|
|
@@ -34,6 +40,8 @@ export type UsersPageData = {
|
|
|
34
40
|
currentUser: UserData | null;
|
|
35
41
|
rolesOptions: RoleData[];
|
|
36
42
|
};
|
|
43
|
+
hasError?: boolean;
|
|
44
|
+
error?: ErrorBoundaryProps;
|
|
37
45
|
};
|
|
38
46
|
|
|
39
47
|
export type UsersPageQuery = GetUsersByOrgUnitIdServiceProps & {
|
|
@@ -42,9 +50,9 @@ export type UsersPageQuery = GetUsersByOrgUnitIdServiceProps & {
|
|
|
42
50
|
page?: string;
|
|
43
51
|
};
|
|
44
52
|
|
|
45
|
-
|
|
53
|
+
const loaderFunction = async (
|
|
46
54
|
data: LoaderData<UsersPageQuery>
|
|
47
|
-
): Promise<UsersPageData> {
|
|
55
|
+
): Promise<UsersPageData> => {
|
|
48
56
|
const { cookie, userId, ...clientContext } = await getClientContext(data);
|
|
49
57
|
|
|
50
58
|
const { orgUnitId, search = "", page = "1" } = data.query;
|
|
@@ -97,12 +105,22 @@ export async function loader(
|
|
|
97
105
|
rolesOptions,
|
|
98
106
|
},
|
|
99
107
|
};
|
|
100
|
-
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
111
|
+
componentName: "UsersPage",
|
|
112
|
+
redirectToError: true,
|
|
113
|
+
});
|
|
101
114
|
|
|
102
|
-
const UsersPage = ({ data, context }: UsersPageData) => (
|
|
115
|
+
const UsersPage = ({ data, context, hasError, error }: UsersPageData) => (
|
|
103
116
|
<BuyerPortalProvider {...context}>
|
|
104
|
-
<UsersLayout data={data} />
|
|
117
|
+
{hasError ? <ErrorTabsLayout error={error} /> : <UsersLayout data={data} />}
|
|
105
118
|
</BuyerPortalProvider>
|
|
106
119
|
);
|
|
107
120
|
|
|
108
|
-
export default UsersPage
|
|
121
|
+
export default withErrorBoundary(UsersPage, {
|
|
122
|
+
tags: {
|
|
123
|
+
component: "UsersPage",
|
|
124
|
+
errorType: "users_error",
|
|
125
|
+
},
|
|
126
|
+
});
|