@vtex/faststore-plugin-buyer-portal 1.1.116-poc-4 → 1.1.116-poc-6
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/src/features/contracts/services/get-contract-details.service.ts +4 -0
- package/src/features/org-units/clients/OrgUnitClient.ts +2 -15
- package/src/features/org-units/services/get-org-unit-basic-data.service.ts +4 -0
- package/src/features/org-units/services/get-org-unit-by-user-id.service.ts +4 -0
- package/src/features/org-units/types/OrgUnitSummaryData.ts +18 -0
- package/src/features/org-units/types/index.ts +2 -0
- package/src/features/profile/layouts/ProfileLayout/ProfileLayout.tsx +12 -10
- package/src/features/shared/layouts/LoadingTabsLayout/LoadingTabsLayout.tsx +4 -0
- package/src/features/users/services/get-user-by-id.service.ts +4 -0
- package/src/pages/org-unit-details.tsx +8 -7
package/package.json
CHANGED
|
@@ -15,6 +15,10 @@ const getContractDetailsFunction = async ({
|
|
|
15
15
|
cookie,
|
|
16
16
|
unitId,
|
|
17
17
|
}: GetContractDetailsServiceProps) => {
|
|
18
|
+
if (!unitId || !contractId) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
const { contract } = await contractsClient.getContractDetails(
|
|
19
23
|
unitId,
|
|
20
24
|
contractId,
|
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
OrgUnitSummaryData,
|
|
7
7
|
OrgUnitSearchParams,
|
|
8
8
|
OrgUnitSearchResponse,
|
|
9
|
+
OrgUnitUserData,
|
|
9
10
|
} from "../types";
|
|
10
11
|
|
|
11
12
|
export class OrgUnitClient extends Client {
|
|
@@ -30,21 +31,7 @@ export class OrgUnitClient extends Client {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
getOrgUnitByUserId(userId: string, cookie: string) {
|
|
33
|
-
return this.get<{
|
|
34
|
-
orgUnit: {
|
|
35
|
-
createdAt: string;
|
|
36
|
-
updatedAt: string;
|
|
37
|
-
name: string;
|
|
38
|
-
path: {
|
|
39
|
-
ids: string;
|
|
40
|
-
names: string;
|
|
41
|
-
};
|
|
42
|
-
id: string;
|
|
43
|
-
customerGroup: {
|
|
44
|
-
customerIds: string[];
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
}>(`users/${userId}/units`, {
|
|
34
|
+
return this.get<OrgUnitUserData>(`users/${userId}/units`, {
|
|
48
35
|
headers: {
|
|
49
36
|
Cookie: cookie,
|
|
50
37
|
},
|
|
@@ -25,3 +25,21 @@ export type OrgUnitBasicData = Pick<OrgUnitSummaryData, "id" | "name"> & {
|
|
|
25
25
|
ids: string;
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
|
+
|
|
29
|
+
export type UserOrgUnit = {
|
|
30
|
+
createdAt: string;
|
|
31
|
+
updatedAt: string;
|
|
32
|
+
name: string;
|
|
33
|
+
path: {
|
|
34
|
+
ids: string;
|
|
35
|
+
names: string;
|
|
36
|
+
};
|
|
37
|
+
id: string;
|
|
38
|
+
customerGroup: {
|
|
39
|
+
customerIds: string[];
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type OrgUnitUserData = {
|
|
44
|
+
orgUnit: UserOrgUnit;
|
|
45
|
+
};
|
|
@@ -10,12 +10,14 @@ export type ProfileLayoutProps = {
|
|
|
10
10
|
orgUnitId: string;
|
|
11
11
|
contractId: string;
|
|
12
12
|
userId: string;
|
|
13
|
+
loading?: boolean;
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
export const ProfileLayout = ({
|
|
16
17
|
orgUnitId,
|
|
17
18
|
contractId,
|
|
18
19
|
userId,
|
|
20
|
+
loading = true,
|
|
19
21
|
}: ProfileLayoutProps) => {
|
|
20
22
|
const { orgUnit, isOrgUnitLoading } = useOrgUnitBasicData(orgUnitId);
|
|
21
23
|
|
|
@@ -26,7 +28,7 @@ export const ProfileLayout = ({
|
|
|
26
28
|
|
|
27
29
|
const { user, isUserLoading } = useGetUserById({ orgUnitId, userId });
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
loading = isContractLoading || isOrgUnitLoading || isUserLoading;
|
|
30
32
|
|
|
31
33
|
const creationDate = contract
|
|
32
34
|
? new Date(contract.creationDate).toLocaleDateString("en-US", {
|
|
@@ -55,6 +57,15 @@ export const ProfileLayout = ({
|
|
|
55
57
|
<section data-fs-bp-profile>
|
|
56
58
|
<HeaderInside title="Profile" />
|
|
57
59
|
|
|
60
|
+
{loading && !contract && (
|
|
61
|
+
<Skeleton
|
|
62
|
+
size={{
|
|
63
|
+
width: "100%",
|
|
64
|
+
height: "8rem",
|
|
65
|
+
}}
|
|
66
|
+
/>
|
|
67
|
+
)}
|
|
68
|
+
|
|
58
69
|
{contract && (
|
|
59
70
|
<div data-fs-bp-profile-details>
|
|
60
71
|
<span data-fs-bp-profile-details-title>Details</span>
|
|
@@ -90,15 +101,6 @@ export const ProfileLayout = ({
|
|
|
90
101
|
<hr data-fs-bp-profile-divider />
|
|
91
102
|
</div>
|
|
92
103
|
)}
|
|
93
|
-
|
|
94
|
-
{loading && (
|
|
95
|
-
<Skeleton
|
|
96
|
-
size={{
|
|
97
|
-
width: "100%",
|
|
98
|
-
height: "8rem",
|
|
99
|
-
}}
|
|
100
|
-
/>
|
|
101
|
-
)}
|
|
102
104
|
</section>
|
|
103
105
|
</ContractTabsLayout>
|
|
104
106
|
</GlobalLayout>
|
|
@@ -33,6 +33,8 @@ export const LoadingTabsLayoutContent = ({
|
|
|
33
33
|
);
|
|
34
34
|
|
|
35
35
|
export const LoadingTabsLayout = ({ children }: LoadingTabsLayoutProps) => {
|
|
36
|
+
console.log("Enter loading layout");
|
|
37
|
+
|
|
36
38
|
const { routerLoading, nextRoute } = useRouterLoading();
|
|
37
39
|
const [shouldShowLoading, setShouldShowLoading] = useState(false);
|
|
38
40
|
const wasLoadingRef = useRef(false);
|
|
@@ -65,6 +67,8 @@ export const LoadingTabsLayout = ({ children }: LoadingTabsLayoutProps) => {
|
|
|
65
67
|
|
|
66
68
|
const pageTitle = layoutConfig.pageTitle;
|
|
67
69
|
|
|
70
|
+
console.log(">>>TabsLayout", layoutConfig.layout);
|
|
71
|
+
|
|
68
72
|
switch (layoutConfig.layout) {
|
|
69
73
|
case "ContractTabsLayout":
|
|
70
74
|
return (
|
|
@@ -12,6 +12,10 @@ export const getUserByIdService = async ({
|
|
|
12
12
|
cookie: string;
|
|
13
13
|
}): Promise<UserData | null> => {
|
|
14
14
|
try {
|
|
15
|
+
if (!userId || orgUnitId) {
|
|
16
|
+
return {} as UserData;
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
const { email, name, orgUnit, role } = await usersClient.getUserById(
|
|
16
20
|
orgUnitId,
|
|
17
21
|
userId,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OrgUnitsDetailsLayout } from "../features/org-units/layouts";
|
|
2
|
-
import {
|
|
2
|
+
import { withErrorBoundary } from "../features/shared/components";
|
|
3
3
|
import { ErrorBoundaryProps } from "../features/shared/components/ErrorBoundary/types";
|
|
4
4
|
import { useAuth } from "../features/shared/hooks";
|
|
5
5
|
import { ErrorTabsLayout } from "../features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout";
|
|
@@ -31,12 +31,13 @@ type OrgUnitDetailsPageQuery = {
|
|
|
31
31
|
orgUnitId: string;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
const
|
|
34
|
+
export const loader = async (
|
|
35
35
|
data: LoaderData<OrgUnitDetailsPageQuery>
|
|
36
36
|
): Promise<OrgUnitDetailsPageData> => {
|
|
37
37
|
const { orgUnitId } = data.query;
|
|
38
38
|
|
|
39
39
|
const { cookie, userId, ...clientContext } = await getClientContext(data);
|
|
40
|
+
console.log(">>> Data", data);
|
|
40
41
|
|
|
41
42
|
return {
|
|
42
43
|
data: {
|
|
@@ -50,10 +51,10 @@ const loaderFunction = async (
|
|
|
50
51
|
};
|
|
51
52
|
};
|
|
52
53
|
|
|
53
|
-
export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
54
|
+
// export const loader = withLoaderErrorBoundary(loaderFunction, {
|
|
55
|
+
// componentName: "OrgUnitDetailsPage",
|
|
56
|
+
// redirectToError: true,
|
|
57
|
+
// });
|
|
57
58
|
|
|
58
59
|
const OrgUnitDetailsPage = ({
|
|
59
60
|
data,
|
|
@@ -68,7 +69,7 @@ const OrgUnitDetailsPage = ({
|
|
|
68
69
|
console.log(">> Context", data.cookie);
|
|
69
70
|
|
|
70
71
|
if (isLoading || isAuthenticated === null) {
|
|
71
|
-
return <
|
|
72
|
+
return <OrgUnitsDetailsLayout loading={true} orgUnitId="" userId="" />;
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
return (
|