@vtex/faststore-plugin-buyer-portal 1.1.103 → 1.1.104-experimental.4
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/shared/components/Error/Error.tsx +21 -9
- package/src/features/shared/components/ErrorBoundary/types.ts +2 -0
- package/src/features/shared/layouts/BaseTabsLayout/SidebarMenu.tsx +4 -4
- package/src/features/shared/layouts/ErrorTabsLayout/ErrorTabsLayout.tsx +7 -3
- package/src/features/shared/utils/buyerPortalRoutes.ts +7 -3
- package/src/features/shared/utils/withLoaderErrorBoundary.ts +2 -0
- package/src/pages/org-unit-details.tsx +5 -1
- package/src/pages/profile.tsx +7 -1
package/package.json
CHANGED
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
import { Icon } from "../Icon";
|
|
3
3
|
|
|
4
4
|
export type ErrorProps = {
|
|
5
|
-
error?:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
error?: {
|
|
6
|
+
error: Error;
|
|
7
|
+
query?: unknown;
|
|
8
|
+
rawData?: unknown;
|
|
9
|
+
tags?: {
|
|
10
|
+
component: string;
|
|
11
|
+
errorType: string;
|
|
12
|
+
};
|
|
9
13
|
};
|
|
10
14
|
};
|
|
11
15
|
|
|
12
|
-
export default function Error({ error
|
|
16
|
+
export default function Error({ error }: ErrorProps) {
|
|
13
17
|
return (
|
|
14
18
|
<div data-fs-bp-error>
|
|
15
19
|
<Icon name="Warning" width={48} height={48} data-fs-icon-loading="true" />
|
|
@@ -18,11 +22,19 @@ export default function Error({ error, tags }: ErrorProps) {
|
|
|
18
22
|
Try again
|
|
19
23
|
</button>
|
|
20
24
|
<div data-fs-bp-error-details>
|
|
21
|
-
<span data-fs-bp-error-details-type>{tags?.errorType}</span>
|
|
25
|
+
<span data-fs-bp-error-details-type>{error?.tags?.errorType}</span>
|
|
22
26
|
<h2 data-fs-bp-error-details-title>Error Details</h2>
|
|
23
|
-
<p data-fs-bp-error-details-message>{error?.message}</p>
|
|
24
|
-
<p data-fs-bp-error-details-stack>Stack: {error?.stack}</p>
|
|
25
|
-
<p data-fs-bp-error-details-component>
|
|
27
|
+
<p data-fs-bp-error-details-message>{error?.error.message}</p>
|
|
28
|
+
<p data-fs-bp-error-details-stack>Stack: {error?.error.stack}</p>
|
|
29
|
+
<p data-fs-bp-error-details-component>
|
|
30
|
+
Component: {error?.tags?.component}
|
|
31
|
+
</p>
|
|
32
|
+
<p data-fs-bp-error-details-query>
|
|
33
|
+
Query: {JSON.stringify(error?.query)}
|
|
34
|
+
</p>
|
|
35
|
+
<p data-fs-bp-error-details-raw-data>
|
|
36
|
+
Raw Data: {JSON.stringify(error?.rawData)}
|
|
37
|
+
</p>
|
|
26
38
|
</div>
|
|
27
39
|
</div>
|
|
28
40
|
);
|
|
@@ -26,8 +26,8 @@ export const SidebarMenu = ({ ...otherProps }: SidebarMenuProps) => {
|
|
|
26
26
|
|
|
27
27
|
const router = useRouter();
|
|
28
28
|
|
|
29
|
-
const orgUnitId = router.query.orgUnitId as string;
|
|
30
|
-
const customerId = router.query.contractId as string;
|
|
29
|
+
const orgUnitId = (router.query.orgUnitId as string) || "";
|
|
30
|
+
const customerId = (router.query.contractId as string) || "";
|
|
31
31
|
|
|
32
32
|
const idContract =
|
|
33
33
|
(currentContract?.id
|
|
@@ -38,8 +38,8 @@ export const SidebarMenu = ({ ...otherProps }: SidebarMenuProps) => {
|
|
|
38
38
|
<aside data-fs-bp-sidebar-menu {...otherProps}>
|
|
39
39
|
<VerticalNav.Menu title="Contract">
|
|
40
40
|
{getContractSettingsLinks({
|
|
41
|
-
orgUnitId: orgUnitId
|
|
42
|
-
contractId: customerId
|
|
41
|
+
orgUnitId: orgUnitId || currentOrgUnit?.id || "",
|
|
42
|
+
contractId: customerId || idContract,
|
|
43
43
|
}).map((option) => (
|
|
44
44
|
<VerticalNav.Link key={option.name} link={option.link}>
|
|
45
45
|
{option.name}
|
|
@@ -15,6 +15,8 @@ export type ErrorTabsLayoutContentProps = {
|
|
|
15
15
|
title?: string;
|
|
16
16
|
error?: {
|
|
17
17
|
error: Error;
|
|
18
|
+
query?: unknown;
|
|
19
|
+
rawData?: unknown;
|
|
18
20
|
tags: {
|
|
19
21
|
component: string;
|
|
20
22
|
errorType: string;
|
|
@@ -26,6 +28,8 @@ export type ErrorTabsLayoutProps = {
|
|
|
26
28
|
children?: ReactNode;
|
|
27
29
|
error?: {
|
|
28
30
|
error: Error;
|
|
31
|
+
query?: unknown;
|
|
32
|
+
rawData?: unknown;
|
|
29
33
|
tags: {
|
|
30
34
|
component: string;
|
|
31
35
|
errorType: string;
|
|
@@ -40,7 +44,7 @@ export const ErrorTabsLayoutContent = ({
|
|
|
40
44
|
<div>
|
|
41
45
|
<section data-fs-bp-profile>
|
|
42
46
|
<HeaderInside title={title} />
|
|
43
|
-
<Error error={error
|
|
47
|
+
<Error error={error} />
|
|
44
48
|
</section>
|
|
45
49
|
</div>
|
|
46
50
|
);
|
|
@@ -54,8 +58,8 @@ export const ErrorTabsLayout = ({ children, error }: ErrorTabsLayoutProps) => {
|
|
|
54
58
|
currentContract: contract,
|
|
55
59
|
} = useBuyerPortal();
|
|
56
60
|
|
|
57
|
-
const orgUnitId = router.query.orgUnitId as string;
|
|
58
|
-
const customerId = router.query.contractId as string;
|
|
61
|
+
const orgUnitId = (router.query.orgUnitId as string) || "";
|
|
62
|
+
const customerId = (router.query.contractId as string) || "";
|
|
59
63
|
|
|
60
64
|
const layoutConfig = getTabsLayoutConfigFromRoute(router.route);
|
|
61
65
|
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
const base = "/pvt/organization-account";
|
|
2
2
|
|
|
3
3
|
function replaceParams(template: string, params: Record<string, string>) {
|
|
4
|
-
return Object.entries(params)
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
return Object.entries(params)
|
|
5
|
+
.reduce((url, [key, value]) => {
|
|
6
|
+
// Handle empty or undefined values by replacing with empty string
|
|
7
|
+
const cleanValue = value || "";
|
|
8
|
+
return url.replace(`[${key}]`, cleanValue);
|
|
9
|
+
}, template)
|
|
10
|
+
.replace(/\/+/g, "/"); // Remove consecutive slashes
|
|
7
11
|
}
|
|
8
12
|
|
|
9
13
|
export const buyerPortalRoutes = {
|
|
@@ -27,6 +27,8 @@ export function withLoaderErrorBoundary<TQuery, TReturn>(
|
|
|
27
27
|
message: (error as Error).message,
|
|
28
28
|
name: (error as Error).name,
|
|
29
29
|
stack: (error as Error).stack,
|
|
30
|
+
query: data.query,
|
|
31
|
+
rawData: data,
|
|
30
32
|
},
|
|
31
33
|
tags: {
|
|
32
34
|
component: componentName || "Unknown",
|
|
@@ -46,7 +46,11 @@ type OrgUnitDetailsPageQuery = {
|
|
|
46
46
|
const loaderFunction = async (
|
|
47
47
|
data: LoaderData<OrgUnitDetailsPageQuery>
|
|
48
48
|
): Promise<OrgUnitDetailsPageData> => {
|
|
49
|
-
const { orgUnitId } = data.query;
|
|
49
|
+
const { orgUnitId } = data.query ?? {};
|
|
50
|
+
|
|
51
|
+
if (!orgUnitId) {
|
|
52
|
+
throw new Error(`Missing required query param: orgUnitId=${orgUnitId}`);
|
|
53
|
+
}
|
|
50
54
|
|
|
51
55
|
const { cookie, userId, ...clientContext } = await getClientContext(data);
|
|
52
56
|
|
package/src/pages/profile.tsx
CHANGED
|
@@ -42,7 +42,13 @@ export async function loaderFunction(
|
|
|
42
42
|
const { customerId, cookie, userId, ...clientContext } =
|
|
43
43
|
await getClientContext(data);
|
|
44
44
|
|
|
45
|
-
const { contractId, orgUnitId } = data.query;
|
|
45
|
+
const { contractId, orgUnitId } = data.query ?? {};
|
|
46
|
+
|
|
47
|
+
if (!contractId || !orgUnitId) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
`Missing required query params: contractId=${contractId}, orgUnitId=${orgUnitId}`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
46
52
|
|
|
47
53
|
const [orgUnit, contract, user] = await Promise.all([
|
|
48
54
|
getOrgUnitBasicDataService({
|