@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.
Files changed (55) hide show
  1. package/package.json +1 -1
  2. package/public/buyer-portal-icons.svg +1 -1
  3. package/src/features/addresses/services/get-addresses-by-unit-id.service.ts +13 -1
  4. package/src/features/addresses/services/get-addresses.service.ts +15 -2
  5. package/src/features/buying-policies/services/get-buying-policies.service.ts +19 -21
  6. package/src/features/contracts/services/get-contract-details.service.ts +13 -1
  7. package/src/features/contracts/services/get-contracts-org-by-unit-id.service.ts +18 -11
  8. package/src/features/contracts/services/update-contract-status.service.ts +18 -11
  9. package/src/features/org-units/components/AddAllToOrgUnitDropdown/AddAllToOrgUnitDropdown.tsx +3 -1
  10. package/src/features/org-units/components/OrgUnitBreadcrumb/OrgUnitBreadcrumb.tsx +2 -0
  11. package/src/features/org-units/components/OrgUnitBreadcrumb/OrgUnitBreadcrumbPath.tsx +12 -12
  12. package/src/features/org-units/components/OrgUnitBreadcrumb/org-unit-breadcrumb.scss +47 -36
  13. package/src/features/org-units/types/OrgUnitBreadcrumbTypes.ts +2 -0
  14. package/src/features/profile/layouts/ProfileLayout/profile-layout.scss +1 -0
  15. package/src/features/shared/clients/Client.ts +84 -8
  16. package/src/features/shared/components/BuyerPortalProvider/BuyerPortalProvider.tsx +4 -1
  17. package/src/features/shared/components/Error/Error.tsx +31 -0
  18. package/src/features/shared/components/Error/error.scss +71 -0
  19. package/src/features/shared/components/ErrorBoundary/ErrorBoundary.tsx +63 -0
  20. package/src/features/shared/components/ErrorBoundary/types.ts +14 -0
  21. package/src/features/shared/components/index.ts +3 -0
  22. package/src/features/shared/components/withErrorBoundary/withErrorBoundary.tsx +35 -0
  23. package/src/features/shared/layouts/BaseTabsLayout/Navbar.tsx +1 -1
  24. package/src/features/shared/layouts/BaseTabsLayout/SidebarMenu.tsx +9 -2
  25. package/src/features/shared/layouts/BaseTabsLayout/base-tabs-layout.scss +9 -6
  26. package/src/features/shared/layouts/ContractTabsLayout/ContractTabsLayout.tsx +4 -2
  27. package/src/features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout.tsx +119 -0
  28. package/src/features/shared/layouts/ErrorTabsLayout/error-tabs-layout.scss +1 -0
  29. package/src/features/shared/utils/environment.ts +41 -0
  30. package/src/features/shared/utils/extractErrorMessage.ts +22 -0
  31. package/src/features/shared/utils/getHome.tsx +5 -0
  32. package/src/features/shared/utils/index.ts +2 -0
  33. package/src/features/shared/utils/withClientErrorBoundary.ts +61 -0
  34. package/src/features/shared/utils/withLoaderErrorBoundary.ts +46 -0
  35. package/src/features/users/clients/UsersClient.ts +0 -1
  36. package/src/pages/address-details.tsx +38 -11
  37. package/src/pages/addresses.tsx +35 -6
  38. package/src/pages/budgets-details.tsx +38 -8
  39. package/src/pages/budgets.tsx +33 -8
  40. package/src/pages/buying-policies.tsx +36 -12
  41. package/src/pages/buying-policy-details.tsx +38 -8
  42. package/src/pages/collections.tsx +36 -12
  43. package/src/pages/cost-centers.tsx +38 -8
  44. package/src/pages/credit-cards.tsx +38 -8
  45. package/src/pages/home.tsx +22 -5
  46. package/src/pages/org-unit-details.tsx +43 -7
  47. package/src/pages/org-units.tsx +39 -8
  48. package/src/pages/payment-methods.tsx +38 -8
  49. package/src/pages/po-numbers.tsx +38 -8
  50. package/src/pages/profile.tsx +31 -6
  51. package/src/pages/releases.tsx +33 -8
  52. package/src/pages/role-details.tsx +39 -7
  53. package/src/pages/roles.tsx +28 -7
  54. package/src/pages/user-details.tsx +39 -8
  55. package/src/pages/users.tsx +25 -7
@@ -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 { 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 { 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
- export async function loader(
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 UserDetailsPage = ({ data, context }: UserDetailsPageData) => (
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
- <UserDetailsLayout data={data} />
104
+ {hasError ? (
105
+ <ErrorTabsLayout error={error} />
106
+ ) : (
107
+ <UserDetailsLayout data={data} />
108
+ )}
84
109
  </BuyerPortalProvider>
85
110
  );
86
- export default UserDetailsPage;
111
+
112
+ export default withErrorBoundary(UserDetailsPage, {
113
+ tags: {
114
+ component: "UserDetailsPage",
115
+ errorType: "user_details_error",
116
+ },
117
+ });
@@ -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 { BuyerPortalProvider } from "../features/shared/components";
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
- export async function loader(
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
+ });