@vtex/faststore-plugin-buyer-portal 1.3.3 → 1.3.5

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 CHANGED
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.3.5] - 2025-10-17
11
+
12
+ ### Fixed
13
+
14
+ - Budget Screen showing `remaining` ammount when it should have been showing `total`
15
+
16
+ ## [1.3.4] - 2025-10-16
17
+
18
+ - Error boundary:
19
+ - Updating the authentication loader to provide detailed error context.
20
+
10
21
  ## [1.3.3] - 2025-10-16
11
22
 
12
23
  ### Added
@@ -115,10 +126,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
115
126
  - Add CHANGELOG file
116
127
  - Add README file
117
128
 
118
- [unreleased]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/1.3.3...HEAD
129
+ [unreleased]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/1.3.5...HEAD
119
130
  [1.2.3]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.2.2...1.2.3
120
131
  [1.2.3]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.2.3
121
132
  [1.2.4]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.2.4
122
133
  [1.3.2]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.3.2
123
-
124
134
  [1.3.3]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.3.3
135
+ [1.3.4]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.3.4
136
+
137
+ [1.3.5]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.3.5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/faststore-plugin-buyer-portal",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "A plugin for faststore with buyer portal",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,7 +22,7 @@ export const BudgetRemainingBalance = ({
22
22
  <span data-fs-bp-budget-remaining-balance-label-used>
23
23
  {formatCurrency(Math.abs(used))}{" "}
24
24
  <span data-fs-bp-budget-remaining-balance-label-used-total>
25
- of {formatCurrency(remaining)} used
25
+ of {formatCurrency(total)} used
26
26
  </span>
27
27
  </span>
28
28
  <BudgetProgressBar
@@ -33,6 +33,7 @@
33
33
  padding: var(--fs-spacing-4);
34
34
  border-radius: var(--fs-border-radius-medium);
35
35
  position: relative;
36
+ max-width: 100%;
36
37
 
37
38
  [data-fs-bp-error-details-type] {
38
39
  position: absolute;
@@ -56,6 +57,7 @@
56
57
  font-weight: var(--fs-text-weight-medium);
57
58
  color: #e2e2e2;
58
59
  text-wrap: wrap;
60
+ overflow-wrap: break-word;
59
61
  }
60
62
 
61
63
  [data-fs-bp-error-details-stack] {
@@ -63,12 +65,16 @@
63
65
  margin: var(--fs-spacing-4) 0;
64
66
  font-weight: var(--fs-text-weight-medium);
65
67
  text-wrap: wrap;
68
+ max-width: 100%;
69
+ overflow-wrap: break-word;
66
70
  }
67
71
 
68
72
  [data-fs-bp-error-details-component] {
69
73
  font-size: var(--fs-text-size-2);
70
74
  font-weight: var(--fs-text-weight-medium);
71
75
  text-wrap: wrap;
76
+ overflow-wrap: break-word;
77
+ max-width: 100%;
72
78
  }
73
79
  }
74
80
  }
@@ -1,5 +1,18 @@
1
+ import { ErrorBoundaryProps } from "../components/ErrorBoundary/types";
1
2
  import { ClientContext } from "../utils";
2
3
 
3
4
  export type AuthRouteProps<T> =
4
- | { authorized: true; data: T; clientContext: ClientContext }
5
- | { authorized: false };
5
+ | {
6
+ authorized: true;
7
+ data: T;
8
+ clientContext: ClientContext;
9
+ hasError?: boolean;
10
+ error?: ErrorBoundaryProps;
11
+ }
12
+ | {
13
+ authorized: false;
14
+ hasError?: boolean;
15
+ error?: ErrorBoundaryProps;
16
+ data?: T;
17
+ clientContext?: ClientContext;
18
+ };
@@ -13,4 +13,4 @@ export const LOCAL_STORAGE_LOCATION_EDIT_KEY = "bp_hide_edit_location_confirm";
13
13
  export const LOCAL_STORAGE_RECIPIENT_EDIT_KEY =
14
14
  "bp_hide_edit_recipient_confirm";
15
15
 
16
- export const CURRENT_VERSION = "1.3.3";
16
+ export const CURRENT_VERSION = "1.3.5";
@@ -2,30 +2,42 @@ import { useEffect, type ComponentType } from "react";
2
2
 
3
3
  import { useRouter } from "next/router";
4
4
 
5
+ import { ErrorBoundaryProps } from "../components/ErrorBoundary/types";
6
+
5
7
  import type { AuthRouteProps } from "../types";
6
8
 
7
9
  /**
8
10
  * HOC that checks only for authorization
9
11
  */
10
12
  export const withAuth = <T extends Record<string, unknown>>(
11
- Component: ComponentType<T>
13
+ Component: ComponentType<T & { hasError?: boolean }>
12
14
  ) => {
13
- return function AuthenticatedComponent(props: AuthRouteProps<T>) {
15
+ return function AuthenticatedComponent(
16
+ props: AuthRouteProps<T> & {
17
+ hasError?: boolean;
18
+ error?: ErrorBoundaryProps;
19
+ }
20
+ ) {
14
21
  const router = useRouter();
15
22
 
16
23
  useEffect(() => {
17
24
  // If not authorized, reload the page
18
- if (!props?.authorized) {
25
+ if (!props?.authorized && !props?.hasError) {
19
26
  router.reload();
20
27
  }
21
- }, [props?.authorized, router]);
28
+ }, [props?.authorized, props?.hasError, router]);
22
29
 
23
- // If not authorized, render nothing
24
- if (!props?.authorized) {
30
+ if (!props?.authorized && !props?.hasError && !props?.error) {
25
31
  return null;
26
32
  }
27
33
 
28
34
  // If authorized, render the component with the data
29
- return <Component {...(props.data as T)} />;
35
+ return (
36
+ <Component
37
+ {...(props.data as T)}
38
+ hasError={props?.hasError}
39
+ error={props?.error}
40
+ />
41
+ );
30
42
  };
31
43
  };
@@ -37,11 +37,23 @@ export const withAuthLoader = async <T>(
37
37
  } catch (error) {
38
38
  console.error("Auth validation failed:", error);
39
39
 
40
- data.res?.writeHead(302, { Location: "/" });
41
- data.res?.end();
42
-
43
40
  return {
44
41
  authorized: false,
42
+ hasError: true,
43
+ error: {
44
+ error: {
45
+ message: (error as Error).message,
46
+ name: (error as Error).name,
47
+ stack: (error as Error).stack || undefined,
48
+ },
49
+ extra: {
50
+ query: data.query,
51
+ },
52
+ tags: {
53
+ component: "AuthLoader",
54
+ errorType: "auth_error",
55
+ },
56
+ },
45
57
  };
46
58
  }
47
59
  };
@@ -3,6 +3,7 @@ import { useEffect, type ComponentType } from "react";
3
3
  import { useRouter } from "next/router";
4
4
 
5
5
  import { BuyerPortalProvider } from "../components";
6
+ import { ErrorBoundaryProps } from "../components/ErrorBoundary/types";
6
7
 
7
8
  import type { AuthRouteProps } from "../types";
8
9
  import type { ClientContext } from "./getClientContext";
@@ -13,7 +14,12 @@ import type { ClientContext } from "./getClientContext";
13
14
  export const withAuthProvider = <T,>(
14
15
  Component: ComponentType<T & { clientContext: ClientContext }>
15
16
  ) => {
16
- return function WrappedPage(props: AuthRouteProps<T>) {
17
+ return function WrappedPage(
18
+ props: AuthRouteProps<T> & {
19
+ hasError?: boolean;
20
+ error?: ErrorBoundaryProps;
21
+ }
22
+ ) {
17
23
  const router = useRouter();
18
24
 
19
25
  useEffect(() => {
@@ -23,14 +29,18 @@ export const withAuthProvider = <T,>(
23
29
  }
24
30
  }, [props?.authorized, router]);
25
31
 
26
- // Se não está autorizado, não renderiza nada
27
- if (!props?.authorized) {
32
+ if (!props?.authorized && !props?.hasError && !props?.error) {
28
33
  return null;
29
34
  }
30
35
 
31
36
  return (
32
- <BuyerPortalProvider clientContext={props?.clientContext}>
33
- <Component {...props.data} clientContext={props?.clientContext} />
37
+ <BuyerPortalProvider
38
+ clientContext={props?.clientContext as ClientContext}
39
+ >
40
+ <Component
41
+ {...(props.data as T)}
42
+ clientContext={props?.clientContext as ClientContext}
43
+ />
34
44
  </BuyerPortalProvider>
35
45
  );
36
46
  };