@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.
- package/CHANGELOG.md +14 -1
- package/package.json +1 -1
- package/public/buyer-portal-icons.svg +35 -13
- package/src/features/org-units/clients/OrgUnitClient.ts +17 -0
- package/src/features/org-units/components/AddAllToOrgUnitDropdown/AddAllToOrgUnitDropdown.tsx +2 -2
- package/src/features/org-units/components/AuthSetupDrawer/AuthSetupDrawer.tsx +346 -0
- package/src/features/org-units/components/AuthSetupDrawer/auth-setup-drawer.scss +138 -0
- package/src/features/org-units/components/AuthSetupDrawer/index.ts +1 -0
- package/src/features/org-units/components/OrgUnitDetailsDropdownMenu/OrgUnitDetailsDropdownMenu.tsx +80 -0
- package/src/features/org-units/components/OrgUnitDetailsDropdownMenu/index.ts +4 -0
- package/src/features/org-units/components/OrgUnitsDropdownMenu/OrgUnitsDropdownMenu.tsx +2 -2
- package/src/features/org-units/components/index.ts +8 -0
- package/src/features/org-units/hooks/index.ts +2 -0
- package/src/features/org-units/hooks/useGetOrgUnitSettings.ts +20 -0
- package/src/features/org-units/hooks/useOrgUnitByUser.ts +4 -1
- package/src/features/org-units/hooks/useUpdateOrgUnitSettings.ts +27 -0
- package/src/features/org-units/layouts/OrgUnitDetailsLayout/OrgUnitDetailsLayout.tsx +22 -1
- package/src/features/org-units/layouts/OrgUnitDetailsLayout/org-units-details.scss +1 -0
- package/src/features/org-units/services/get-org-unit-settings.service.ts +13 -0
- package/src/features/org-units/services/index.ts +8 -0
- package/src/features/org-units/services/update-org-unit-settings.service.ts +17 -0
- package/src/features/org-units/types/OrgUnitSettings.ts +25 -0
- package/src/features/org-units/types/index.ts +2 -0
- package/src/features/product-assortment/hooks/useGetProductAssortment.ts +52 -0
- package/src/features/product-assortment/hooks/useGetProductAssortmentFromContract.ts +35 -0
- package/src/features/product-assortment/layouts/ProductAssortmentLayout/ProductAssortmentLayout.tsx +55 -12
- package/src/features/product-assortment/layouts/ProductAssortmentLayout/product-assortment-layout.scss +1 -1
- package/src/features/product-assortment/types/index.ts +6 -14
- package/src/features/shared/components/BuyerPortalProvider/BuyerPortalProvider.tsx +5 -0
- package/src/features/shared/components/Toast/Toast.tsx +43 -2
- package/src/features/shared/components/Toast/toast.scss +23 -5
- package/src/features/shared/components/index.ts +1 -0
- package/src/features/shared/hooks/usePageItems.ts +2 -2
- package/src/features/shared/layouts/ContractTabsLayout/ContractTabsLayout.tsx +1 -0
- package/src/features/shared/layouts/LoadingTabsLayout/LoadingTabsLayout.tsx +13 -0
- package/src/features/shared/utils/constants.ts +2 -2
- package/src/features/shared/utils/withBuyerPortal.tsx +4 -1
- package/src/features/users/clients/UsersClient.ts +105 -4
- package/src/features/users/components/CreateUserDrawer/CreateUserDrawer.tsx +1 -1
- package/src/features/users/components/CreateUserDrawerSelector/CreateUserDrawerSelector.tsx +20 -0
- package/src/features/users/components/CreateUserDrawerWithUsername/CreateUserDrawerWithUsername.tsx +696 -0
- package/src/features/users/components/CreateUserDrawerWithUsername/create-user-drawer-with-username.scss +116 -0
- package/src/features/users/components/UserDropdownMenu/user-dropdown-menu.scss +1 -0
- package/src/features/users/components/UsersCard/UsersCard.tsx +2 -2
- package/src/features/users/components/index.ts +5 -0
- package/src/features/users/hooks/index.ts +2 -0
- package/src/features/users/hooks/useAddUserToOrgUnit.ts +12 -5
- package/src/features/users/hooks/useResetPassword.ts +39 -0
- package/src/features/users/hooks/useValidateUsername.ts +38 -0
- package/src/features/users/layouts/UserDetailsLayout/UserDetailsLayout.tsx +10 -0
- package/src/features/users/layouts/UsersLayout/UsersLayout.tsx +55 -10
- package/src/features/users/layouts/UsersLayout/users-layout.scss +19 -0
- package/src/features/users/services/add-user-to-org-unit.service.ts +8 -6
- package/src/features/users/services/get-users-by-org-unit-id.service.ts +1 -0
- package/src/features/users/services/index.ts +10 -0
- package/src/features/users/services/reset-password.service.ts +24 -0
- package/src/features/users/services/validate-username.service.ts +25 -0
- package/src/features/users/types/UserData.ts +1 -0
- package/src/features/users/types/UserDataService.ts +1 -0
- package/src/pages/org-unit-details.tsx +20 -2
- 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
|
-
|
|
17
|
-
|
|
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<
|
|
42
|
+
): Promise<AuthRouteProps<ProductAssortmentPageData>> => {
|
|
24
43
|
const { contractId, orgUnitId, search = "", page: pageString } = data.query;
|
|
25
44
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
87
|
-
drawerProductAssortment,
|
|
88
|
-
isContractEmpty,
|
|
89
|
-
page,
|
|
90
|
-
search,
|
|
86
|
+
data,
|
|
91
87
|
hasError,
|
|
92
88
|
error,
|
|
93
|
-
}:
|
|
89
|
+
}: ProductAssortmentPageData) => (
|
|
94
90
|
<>
|
|
95
91
|
{hasError ? (
|
|
96
92
|
<ErrorTabsLayout error={error} />
|
|
97
93
|
) : (
|
|
98
94
|
<ProductAssortmentLayout
|
|
99
|
-
page={page}
|
|
100
|
-
search={search}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
</>
|