@vtex/faststore-plugin-buyer-portal 1.1.91 → 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/org-units/components/AddAllToOrgUnitDropdown/AddAllToOrgUnitDropdown.tsx +3 -1
- package/src/features/org-units/components/OrgUnitBreadcrumb/OrgUnitBreadcrumb.tsx +2 -0
- package/src/features/org-units/components/OrgUnitBreadcrumb/OrgUnitBreadcrumbPath.tsx +12 -12
- package/src/features/org-units/components/OrgUnitBreadcrumb/org-unit-breadcrumb.scss +47 -36
- package/src/features/org-units/types/OrgUnitBreadcrumbTypes.ts +2 -0
- 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/Navbar.tsx +1 -1
- package/src/features/shared/layouts/BaseTabsLayout/SidebarMenu.tsx +9 -2
- package/src/features/shared/layouts/BaseTabsLayout/base-tabs-layout.scss +9 -6
- 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
package/src/pages/addresses.tsx
CHANGED
|
@@ -5,11 +5,17 @@ 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 {
|
|
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
|
import { getUserByIdService } from "../features/users/services";
|
|
15
21
|
|
|
@@ -30,6 +36,8 @@ export type AddressesPageData = {
|
|
|
30
36
|
currentOrgUnit: OrgUnitBasicData | null;
|
|
31
37
|
currentUser: UserData | null;
|
|
32
38
|
};
|
|
39
|
+
hasError?: boolean;
|
|
40
|
+
error?: ErrorBoundaryProps;
|
|
33
41
|
};
|
|
34
42
|
|
|
35
43
|
export type AddressesPageQuery = GetAddressesServiceProps & {
|
|
@@ -38,9 +46,9 @@ export type AddressesPageQuery = GetAddressesServiceProps & {
|
|
|
38
46
|
page?: string;
|
|
39
47
|
};
|
|
40
48
|
|
|
41
|
-
|
|
49
|
+
const loaderFunction = async (
|
|
42
50
|
data: LoaderData<AddressesPageQuery>
|
|
43
|
-
): Promise<AddressesPageData> {
|
|
51
|
+
): Promise<AddressesPageData> => {
|
|
44
52
|
const { contractId, orgUnitId, search, page: pageString } = data.query;
|
|
45
53
|
|
|
46
54
|
const page = getValidPage(pageString);
|
|
@@ -81,7 +89,12 @@ export async function loader(
|
|
|
81
89
|
currentContract: contract,
|
|
82
90
|
},
|
|
83
91
|
};
|
|
84
|
-
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
95
|
+
componentName: "AddressesPage",
|
|
96
|
+
redirectToError: true,
|
|
97
|
+
});
|
|
85
98
|
|
|
86
99
|
const AddressPage = ({
|
|
87
100
|
data,
|
|
@@ -89,10 +102,26 @@ const AddressPage = ({
|
|
|
89
102
|
page,
|
|
90
103
|
total,
|
|
91
104
|
context,
|
|
105
|
+
hasError,
|
|
106
|
+
error,
|
|
92
107
|
}: AddressesPageData) => (
|
|
93
108
|
<BuyerPortalProvider {...context}>
|
|
94
|
-
|
|
109
|
+
{hasError ? (
|
|
110
|
+
<ErrorTabsLayout error={error} />
|
|
111
|
+
) : (
|
|
112
|
+
<AddressLayout
|
|
113
|
+
addresses={data}
|
|
114
|
+
search={search}
|
|
115
|
+
page={page}
|
|
116
|
+
total={total}
|
|
117
|
+
/>
|
|
118
|
+
)}
|
|
95
119
|
</BuyerPortalProvider>
|
|
96
120
|
);
|
|
97
121
|
|
|
98
|
-
export default AddressPage
|
|
122
|
+
export default withErrorBoundary(AddressPage, {
|
|
123
|
+
tags: {
|
|
124
|
+
component: "AddressesPage",
|
|
125
|
+
errorType: "addresses_error",
|
|
126
|
+
},
|
|
127
|
+
});
|
|
@@ -3,8 +3,17 @@ 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
|
-
|
|
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 BudgetsDetailsData = {
|
|
|
20
29
|
currentContract: ContractData | null;
|
|
21
30
|
currentUser: UserData | null;
|
|
22
31
|
};
|
|
32
|
+
hasError?: boolean;
|
|
33
|
+
error?: ErrorBoundaryProps;
|
|
23
34
|
};
|
|
24
35
|
|
|
25
36
|
export type BudgetsDetailsQuery = {
|
|
@@ -28,9 +39,9 @@ export type BudgetsDetailsQuery = {
|
|
|
28
39
|
budgetId: string;
|
|
29
40
|
};
|
|
30
41
|
|
|
31
|
-
|
|
42
|
+
const loaderFunction = async (
|
|
32
43
|
data: LoaderData<BudgetsDetailsQuery>
|
|
33
|
-
): Promise<BudgetsDetailsData> {
|
|
44
|
+
): Promise<BudgetsDetailsData> => {
|
|
34
45
|
const { customerId, cookie, userId, ...clientContext } =
|
|
35
46
|
await getClientContext(data);
|
|
36
47
|
|
|
@@ -61,12 +72,31 @@ export async function loader(
|
|
|
61
72
|
currentUser: user,
|
|
62
73
|
},
|
|
63
74
|
};
|
|
64
|
-
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
78
|
+
componentName: "BudgetsDetailsPage",
|
|
79
|
+
redirectToError: true,
|
|
80
|
+
});
|
|
65
81
|
|
|
66
|
-
const
|
|
82
|
+
const BudgetsDetailsPage = ({
|
|
83
|
+
budget,
|
|
84
|
+
context,
|
|
85
|
+
hasError,
|
|
86
|
+
error,
|
|
87
|
+
}: BudgetsDetailsData) => (
|
|
67
88
|
<BuyerPortalProvider {...context}>
|
|
68
|
-
|
|
89
|
+
{hasError ? (
|
|
90
|
+
<ErrorTabsLayout error={error} />
|
|
91
|
+
) : (
|
|
92
|
+
<BudgetsDetailsLayout budget={budget} />
|
|
93
|
+
)}
|
|
69
94
|
</BuyerPortalProvider>
|
|
70
95
|
);
|
|
71
96
|
|
|
72
|
-
export default
|
|
97
|
+
export default withErrorBoundary(BudgetsDetailsPage, {
|
|
98
|
+
tags: {
|
|
99
|
+
component: "BudgetsDetailsPage",
|
|
100
|
+
errorType: "budgets_details_error",
|
|
101
|
+
},
|
|
102
|
+
});
|
package/src/pages/budgets.tsx
CHANGED
|
@@ -3,8 +3,17 @@ import { listBudgetsService } from "../features/budgets/services";
|
|
|
3
3
|
import { BudgetListResponse } from "../features/budgets/types";
|
|
4
4
|
import { getContractDetailsService } from "../features/contracts/services";
|
|
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 BudgetPageData = {
|
|
|
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 BudgetPageQuery = {
|
|
@@ -27,9 +38,9 @@ export type BudgetPageQuery = {
|
|
|
27
38
|
orgUnitId: string;
|
|
28
39
|
};
|
|
29
40
|
|
|
30
|
-
|
|
41
|
+
const loaderFunction = async (
|
|
31
42
|
data: LoaderData<BudgetPageQuery>
|
|
32
|
-
): Promise<BudgetPageData> {
|
|
43
|
+
): Promise<BudgetPageData> => {
|
|
33
44
|
const { customerId, cookie, userId, ...clientContext } =
|
|
34
45
|
await getClientContext(data);
|
|
35
46
|
|
|
@@ -62,12 +73,26 @@ export async function loader(
|
|
|
62
73
|
currentUser: user,
|
|
63
74
|
},
|
|
64
75
|
};
|
|
65
|
-
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
79
|
+
componentName: "BudgetsPage",
|
|
80
|
+
redirectToError: true,
|
|
81
|
+
});
|
|
66
82
|
|
|
67
|
-
const ContractsPage = ({ data, context }: BudgetPageData) => (
|
|
83
|
+
const ContractsPage = ({ data, context, hasError, error }: BudgetPageData) => (
|
|
68
84
|
<BuyerPortalProvider {...context}>
|
|
69
|
-
|
|
85
|
+
{hasError ? (
|
|
86
|
+
<ErrorTabsLayout error={error} />
|
|
87
|
+
) : (
|
|
88
|
+
<BudgetsLayout data={data} />
|
|
89
|
+
)}
|
|
70
90
|
</BuyerPortalProvider>
|
|
71
91
|
);
|
|
72
92
|
|
|
73
|
-
export default ContractsPage
|
|
93
|
+
export default withErrorBoundary(ContractsPage, {
|
|
94
|
+
tags: {
|
|
95
|
+
component: "BudgetsPage",
|
|
96
|
+
errorType: "budgets_error",
|
|
97
|
+
},
|
|
98
|
+
});
|
|
@@ -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
|
+
});
|