@vtex/faststore-plugin-buyer-portal 1.3.46 → 1.3.48

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 (61) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/package.json +1 -1
  3. package/public/buyer-portal-icons.svg +35 -13
  4. package/src/features/org-units/clients/OrgUnitClient.ts +17 -0
  5. package/src/features/org-units/components/AddAllToOrgUnitDropdown/AddAllToOrgUnitDropdown.tsx +2 -2
  6. package/src/features/org-units/components/AuthSetupDrawer/AuthSetupDrawer.tsx +346 -0
  7. package/src/features/org-units/components/AuthSetupDrawer/auth-setup-drawer.scss +138 -0
  8. package/src/features/org-units/components/AuthSetupDrawer/index.ts +1 -0
  9. package/src/features/org-units/components/OrgUnitDetailsDropdownMenu/OrgUnitDetailsDropdownMenu.tsx +80 -0
  10. package/src/features/org-units/components/OrgUnitDetailsDropdownMenu/index.ts +4 -0
  11. package/src/features/org-units/components/OrgUnitsDropdownMenu/OrgUnitsDropdownMenu.tsx +2 -2
  12. package/src/features/org-units/components/index.ts +8 -0
  13. package/src/features/org-units/hooks/index.ts +2 -0
  14. package/src/features/org-units/hooks/useGetOrgUnitSettings.ts +20 -0
  15. package/src/features/org-units/hooks/useOrgUnitByUser.ts +4 -1
  16. package/src/features/org-units/hooks/useUpdateOrgUnitSettings.ts +27 -0
  17. package/src/features/org-units/layouts/OrgUnitDetailsLayout/OrgUnitDetailsLayout.tsx +22 -1
  18. package/src/features/org-units/layouts/OrgUnitDetailsLayout/org-units-details.scss +1 -0
  19. package/src/features/org-units/services/get-org-unit-settings.service.ts +13 -0
  20. package/src/features/org-units/services/index.ts +8 -0
  21. package/src/features/org-units/services/update-org-unit-settings.service.ts +17 -0
  22. package/src/features/org-units/types/OrgUnitSettings.ts +25 -0
  23. package/src/features/org-units/types/index.ts +2 -0
  24. package/src/features/product-assortment/hooks/useGetProductAssortment.ts +52 -0
  25. package/src/features/product-assortment/hooks/useGetProductAssortmentFromContract.ts +35 -0
  26. package/src/features/product-assortment/layouts/ProductAssortmentLayout/ProductAssortmentLayout.tsx +55 -12
  27. package/src/features/product-assortment/layouts/ProductAssortmentLayout/product-assortment-layout.scss +1 -1
  28. package/src/features/product-assortment/types/index.ts +6 -14
  29. package/src/features/shared/components/BuyerPortalProvider/BuyerPortalProvider.tsx +5 -0
  30. package/src/features/shared/components/Toast/Toast.tsx +43 -2
  31. package/src/features/shared/components/Toast/toast.scss +23 -5
  32. package/src/features/shared/components/index.ts +1 -0
  33. package/src/features/shared/hooks/usePageItems.ts +2 -2
  34. package/src/features/shared/layouts/ContractTabsLayout/ContractTabsLayout.tsx +1 -0
  35. package/src/features/shared/layouts/LoadingTabsLayout/LoadingTabsLayout.tsx +13 -0
  36. package/src/features/shared/utils/constants.ts +2 -2
  37. package/src/features/shared/utils/withBuyerPortal.tsx +4 -1
  38. package/src/features/users/clients/UsersClient.ts +105 -4
  39. package/src/features/users/components/CreateUserDrawer/CreateUserDrawer.tsx +1 -1
  40. package/src/features/users/components/CreateUserDrawerSelector/CreateUserDrawerSelector.tsx +20 -0
  41. package/src/features/users/components/CreateUserDrawerWithUsername/CreateUserDrawerWithUsername.tsx +696 -0
  42. package/src/features/users/components/CreateUserDrawerWithUsername/create-user-drawer-with-username.scss +116 -0
  43. package/src/features/users/components/UserDropdownMenu/user-dropdown-menu.scss +1 -0
  44. package/src/features/users/components/UsersCard/UsersCard.tsx +2 -2
  45. package/src/features/users/components/index.ts +5 -0
  46. package/src/features/users/hooks/index.ts +2 -0
  47. package/src/features/users/hooks/useAddUserToOrgUnit.ts +12 -5
  48. package/src/features/users/hooks/useResetPassword.ts +39 -0
  49. package/src/features/users/hooks/useValidateUsername.ts +38 -0
  50. package/src/features/users/layouts/UserDetailsLayout/UserDetailsLayout.tsx +10 -0
  51. package/src/features/users/layouts/UsersLayout/UsersLayout.tsx +55 -10
  52. package/src/features/users/layouts/UsersLayout/users-layout.scss +19 -0
  53. package/src/features/users/services/add-user-to-org-unit.service.ts +8 -6
  54. package/src/features/users/services/get-users-by-org-unit-id.service.ts +1 -0
  55. package/src/features/users/services/index.ts +10 -0
  56. package/src/features/users/services/reset-password.service.ts +24 -0
  57. package/src/features/users/services/validate-username.service.ts +25 -0
  58. package/src/features/users/types/UserData.ts +1 -0
  59. package/src/features/users/types/UserDataService.ts +1 -0
  60. package/src/pages/org-unit-details.tsx +20 -2
  61. package/src/pages/productAssortment.tsx +61 -65
@@ -1,80 +1,80 @@
1
1
  import { getContractDetailsService } from "../features/contracts/services";
2
2
  import { getOrgUnitBasicDataService } from "../features/org-units/services";
3
3
  import { ProductAssortmentLayout } from "../features/product-assortment/layouts";
4
- import { getProductAssortmentFromContractService } from "../features/product-assortment/services/get-product-assortment-from-contract.service";
5
- import { getProductAssortmentFromScopeService } from "../features/product-assortment/services/get-product-assortment-from-scope.service";
6
4
  import { withErrorBoundary } from "../features/shared/components";
5
+ import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
7
6
  import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
8
7
  import {
8
+ type ClientContext,
9
9
  getValidPage,
10
- withLoaderErrorBoundary,
11
10
  withAuthLoader,
11
+ withLoaderErrorBoundary,
12
12
  withProviders,
13
13
  } from "../features/shared/utils";
14
+ import { getUserByIdService } from "../features/users/services";
14
15
 
15
- import type {
16
- ProductAssortmentData,
17
- ProductAssortmentQuery,
18
- } from "../features/product-assortment/types";
16
+ import type { ContractData } from "../features/contracts/types";
17
+ import type { OrgUnitBasicData } from "../features/org-units/types";
18
+ import type { ProductAssortmentQuery } from "../features/product-assortment/types";
19
19
  import type { AuthRouteProps, LoaderData } from "../features/shared/types";
20
+ import type { UserData } from "../features/users/types";
21
+
22
+ export type ProductAssortmentPageData = {
23
+ data: {
24
+ orgUnitId: string;
25
+ contractId: string;
26
+ userId: string;
27
+ search: string;
28
+ page: number;
29
+ };
30
+ context: {
31
+ clientContext: ClientContext;
32
+ currentOrgUnit: OrgUnitBasicData;
33
+ currentContract: ContractData | null;
34
+ currentUser: UserData | null;
35
+ };
36
+ hasError?: boolean;
37
+ error?: ErrorBoundaryProps;
38
+ };
20
39
 
21
40
  const loaderFunction = async (
22
41
  data: LoaderData<ProductAssortmentQuery>
23
- ): Promise<AuthRouteProps<ProductAssortmentData>> => {
42
+ ): Promise<AuthRouteProps<ProductAssortmentPageData>> => {
24
43
  const { contractId, orgUnitId, search = "", page: pageString } = data.query;
25
44
 
26
- const page = getValidPage(pageString);
27
-
28
- return withAuthLoader(data, async ({ cookie, ...clientContext }) => {
29
- const [currentOrgUnit, contract] = await Promise.all([
30
- getOrgUnitBasicDataService({ id: orgUnitId, cookie }),
31
- getContractDetailsService({ contractId, cookie, unitId: orgUnitId }),
32
- ]);
33
-
34
- const [enabledAssortment, notAddedAssortments, contractAssortment] =
35
- await Promise.all([
36
- getProductAssortmentFromScopeService({
37
- args: {
38
- cookie,
39
- contractId,
40
- unitId: orgUnitId,
41
- filterByScope: true,
42
- name: search,
43
- page,
44
- },
45
- }),
46
- getProductAssortmentFromScopeService({
47
- args: {
48
- cookie,
49
- contractId,
50
- unitId: orgUnitId,
51
- filterByScope: false,
52
- page: 1,
53
- },
45
+ return withAuthLoader(
46
+ data,
47
+ async ({ customerId, cookie, userId, ...clientContext }) => {
48
+ const [orgUnit, contract, user] = await Promise.all([
49
+ getOrgUnitBasicDataService({
50
+ id: orgUnitId,
51
+ cookie,
54
52
  }),
55
- getProductAssortmentFromContractService({
53
+ getContractDetailsService({
56
54
  contractId,
57
- cookie,
58
55
  unitId: orgUnitId,
56
+ cookie,
59
57
  }),
58
+ getUserByIdService({ orgUnitId, userId, cookie }),
60
59
  ]);
61
60
 
62
- const isContractEmpty =
63
- !contractAssortment || contractAssortment.total === 0;
64
-
65
- return {
66
- productAssortment: enabledAssortment,
67
- drawerProductAssortment: notAddedAssortments,
68
- isContractEmpty,
69
- search,
70
- page,
71
- context: {
72
- clientContext: { cookie, ...clientContext },
73
- currentContract: contract,
74
- currentOrgUnit,
75
- },
76
- };
77
- });
61
+ return {
62
+ data: {
63
+ orgUnitId,
64
+ contractId,
65
+ userId,
66
+ search,
67
+ page: getValidPage(pageString),
68
+ },
69
+ context: {
70
+ clientContext: { customerId, cookie, userId, ...clientContext },
71
+ currentOrgUnit: orgUnit,
72
+ currentContract: contract,
73
+ currentUser: user,
74
+ },
75
+ };
76
+ }
77
+ );
78
78
  };
79
79
 
80
80
  export const loader = withLoaderErrorBoundary(loaderFunction, {
@@ -83,24 +83,20 @@ export const loader = withLoaderErrorBoundary(loaderFunction, {
83
83
  });
84
84
 
85
85
  const ProductAssortmentPage = ({
86
- productAssortment,
87
- drawerProductAssortment,
88
- isContractEmpty,
89
- page,
90
- search,
86
+ data,
91
87
  hasError,
92
88
  error,
93
- }: ProductAssortmentData) => (
89
+ }: ProductAssortmentPageData) => (
94
90
  <>
95
91
  {hasError ? (
96
92
  <ErrorTabsLayout error={error} />
97
93
  ) : (
98
94
  <ProductAssortmentLayout
99
- page={page}
100
- search={search}
101
- initialProductAssortment={productAssortment}
102
- drawerProductAssortment={drawerProductAssortment}
103
- isContractEmpty={isContractEmpty}
95
+ page={data.page}
96
+ search={data.search}
97
+ userId={data.userId}
98
+ orgUnitId={data.orgUnitId}
99
+ contractId={data.contractId}
104
100
  />
105
101
  )}
106
102
  </>