@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
|
@@ -2,11 +2,17 @@ import { BuyingPoliciesLayout } from "../features/buying-policies/layouts";
|
|
|
2
2
|
import { getBuyingPoliciesService } from "../features/buying-policies/services";
|
|
3
3
|
import { getContractDetailsService } from "../features/contracts/services";
|
|
4
4
|
import { getOrgUnitBasicDataService } from "../features/org-units/services";
|
|
5
|
-
import {
|
|
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";
|
|
6
11
|
import {
|
|
7
12
|
type ClientContext,
|
|
8
13
|
getClientContext,
|
|
9
14
|
getValidPage,
|
|
15
|
+
withLoaderErrorBoundary,
|
|
10
16
|
} from "../features/shared/utils";
|
|
11
17
|
import { getUserByIdService } from "../features/users/services";
|
|
12
18
|
|
|
@@ -28,6 +34,8 @@ export type BuyingPoliciesPageData = {
|
|
|
28
34
|
currentOrgUnit: OrgUnitBasicData | null;
|
|
29
35
|
currentUser: UserData | null;
|
|
30
36
|
};
|
|
37
|
+
hasError?: boolean;
|
|
38
|
+
error?: ErrorBoundaryProps;
|
|
31
39
|
};
|
|
32
40
|
|
|
33
41
|
export type BuyingPoliciesPageQuery = GetAddressesServiceProps & {
|
|
@@ -37,9 +45,9 @@ export type BuyingPoliciesPageQuery = GetAddressesServiceProps & {
|
|
|
37
45
|
page?: string;
|
|
38
46
|
};
|
|
39
47
|
|
|
40
|
-
|
|
48
|
+
const loaderFunction = async (
|
|
41
49
|
data: LoaderData<BuyingPoliciesPageQuery>
|
|
42
|
-
): Promise<BuyingPoliciesPageData> {
|
|
50
|
+
): Promise<BuyingPoliciesPageData> => {
|
|
43
51
|
const { contractId, orgUnitId, search = "", page: pageString } = data.query;
|
|
44
52
|
|
|
45
53
|
const page = getValidPage(pageString);
|
|
@@ -87,23 +95,39 @@ export async function loader(
|
|
|
87
95
|
currentContract: contract,
|
|
88
96
|
},
|
|
89
97
|
};
|
|
90
|
-
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
101
|
+
componentName: "BuyingPoliciesPage",
|
|
102
|
+
redirectToError: true,
|
|
103
|
+
});
|
|
91
104
|
|
|
92
|
-
const
|
|
105
|
+
const BuyingPoliciesPage = ({
|
|
93
106
|
buyingPolicies,
|
|
94
107
|
search,
|
|
95
108
|
page,
|
|
96
109
|
context,
|
|
97
110
|
total,
|
|
111
|
+
hasError,
|
|
112
|
+
error,
|
|
98
113
|
}: BuyingPoliciesPageData) => (
|
|
99
114
|
<BuyerPortalProvider {...context}>
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
115
|
+
{hasError ? (
|
|
116
|
+
<ErrorTabsLayout error={error} />
|
|
117
|
+
) : (
|
|
118
|
+
<BuyingPoliciesLayout
|
|
119
|
+
buyingPolicies={buyingPolicies}
|
|
120
|
+
search={search}
|
|
121
|
+
page={page}
|
|
122
|
+
total={total}
|
|
123
|
+
/>
|
|
124
|
+
)}
|
|
106
125
|
</BuyerPortalProvider>
|
|
107
126
|
);
|
|
108
127
|
|
|
109
|
-
export default
|
|
128
|
+
export default withErrorBoundary(BuyingPoliciesPage, {
|
|
129
|
+
tags: {
|
|
130
|
+
component: "BuyingPoliciesPage",
|
|
131
|
+
errorType: "buying_policies_error",
|
|
132
|
+
},
|
|
133
|
+
});
|
|
@@ -2,8 +2,17 @@ import { BuyingPolicyDetailsLayout } from "../features/buying-policies/layouts/B
|
|
|
2
2
|
import { getBuyingPolicyService } from "../features/buying-policies/services";
|
|
3
3
|
import { getContractDetailsService } from "../features/contracts/services";
|
|
4
4
|
import { getOrgUnitBasicDataService } from "../features/org-units/services";
|
|
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 { GetAddressesServiceProps } from "../features/addresses/services";
|
|
@@ -21,6 +30,8 @@ export type BuyingPolicyDetailsPageData = {
|
|
|
21
30
|
currentOrgUnit: OrgUnitBasicData | null;
|
|
22
31
|
currentUser: UserData | null;
|
|
23
32
|
};
|
|
33
|
+
hasError?: boolean;
|
|
34
|
+
error?: ErrorBoundaryProps;
|
|
24
35
|
};
|
|
25
36
|
|
|
26
37
|
export type BuyingPolicyDetailsPageQuery = GetAddressesServiceProps & {
|
|
@@ -29,9 +40,9 @@ export type BuyingPolicyDetailsPageQuery = GetAddressesServiceProps & {
|
|
|
29
40
|
buyingPolicyId: string;
|
|
30
41
|
};
|
|
31
42
|
|
|
32
|
-
|
|
43
|
+
const loaderFunction = async (
|
|
33
44
|
data: LoaderData<BuyingPolicyDetailsPageQuery>
|
|
34
|
-
): Promise<BuyingPolicyDetailsPageData> {
|
|
45
|
+
): Promise<BuyingPolicyDetailsPageData> => {
|
|
35
46
|
const { contractId, orgUnitId, buyingPolicyId } = data.query;
|
|
36
47
|
|
|
37
48
|
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: "BuyingPolicyDetailsPage",
|
|
85
|
+
redirectToError: true,
|
|
86
|
+
});
|
|
71
87
|
|
|
72
|
-
const
|
|
88
|
+
const BuyingPolicyDetailsPage = ({
|
|
89
|
+
data,
|
|
90
|
+
context,
|
|
91
|
+
hasError,
|
|
92
|
+
error,
|
|
93
|
+
}: BuyingPolicyDetailsPageData) => (
|
|
73
94
|
<BuyerPortalProvider {...context}>
|
|
74
|
-
|
|
95
|
+
{hasError ? (
|
|
96
|
+
<ErrorTabsLayout error={error} />
|
|
97
|
+
) : (
|
|
98
|
+
<BuyingPolicyDetailsLayout data={data} />
|
|
99
|
+
)}
|
|
75
100
|
</BuyerPortalProvider>
|
|
76
101
|
);
|
|
77
102
|
|
|
78
|
-
export default
|
|
103
|
+
export default withErrorBoundary(BuyingPolicyDetailsPage, {
|
|
104
|
+
tags: {
|
|
105
|
+
component: "BuyingPolicyDetailsPage",
|
|
106
|
+
errorType: "buying_policy_details_error",
|
|
107
|
+
},
|
|
108
|
+
});
|
|
@@ -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 {
|
|
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
|
-
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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 {
|
|
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 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
|
-
|
|
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 = ({
|
|
72
|
+
const CostCentersPage = ({
|
|
73
|
+
data,
|
|
74
|
+
context,
|
|
75
|
+
hasError,
|
|
76
|
+
error,
|
|
77
|
+
}: CostCentersPageData) => {
|
|
57
78
|
return (
|
|
58
79
|
<BuyerPortalProvider {...context}>
|
|
59
|
-
|
|
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 {
|
|
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 { 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
|
-
|
|
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 = ({
|
|
82
|
+
const CreditCardsPage = ({
|
|
83
|
+
data,
|
|
84
|
+
context,
|
|
85
|
+
hasError,
|
|
86
|
+
error,
|
|
87
|
+
}: CreditCardPageData) => (
|
|
67
88
|
<BuyerPortalProvider {...context}>
|
|
68
|
-
|
|
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
|
+
});
|
package/src/pages/home.tsx
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
import { useRouter } from "next/router";
|
|
2
2
|
|
|
3
3
|
import { getOrgUnitByUserIdService } from "../features/org-units/services";
|
|
4
|
-
import {
|
|
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
|
-
|
|
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 {
|
|
5
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
+
});
|
package/src/pages/org-units.tsx
CHANGED
|
@@ -5,8 +5,17 @@ import {
|
|
|
5
5
|
getOrgUnitByIdService,
|
|
6
6
|
searchOrgUnitsByNameService,
|
|
7
7
|
} from "../features/org-units/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 {
|
|
@@ -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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
+
});
|