@meterbox/customer-portal 0.1.10 → 0.1.12

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/README.md CHANGED
@@ -26,7 +26,6 @@ function handlePlanSelect(plan, billingInterval) {
26
26
  }
27
27
 
28
28
  <CustomerPortal
29
- baseUrl="https://meterbox.ai"
30
29
  customerId="cus_42"
31
30
  customerToken={customerJwt}
32
31
  initialPage="account"
@@ -36,6 +35,9 @@ function handlePlanSelect(plan, billingInterval) {
36
35
  />
37
36
  ```
38
37
 
38
+ It calls `https://meterbox.ai`. To point it elsewhere, wrap it in
39
+ `<MeterboxProvider baseUrl="…">` from `@meterbox/react`, or pass it `baseUrl`.
40
+
39
41
  ## Deep links
40
42
 
41
43
  `initialAction` opens the portal on an action rather than a page, for links
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meterbox/customer-portal",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Drop-in multi-page React customer portal for Meterbox: Account, Plans, Credits. Built on @meterbox/react.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://meterbox.ai",
@@ -17,7 +17,7 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@meterbox/react": "0.1.8"
20
+ "@meterbox/react": "0.1.10"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "react": ">=17",
@@ -9,7 +9,7 @@
9
9
  */
10
10
 
11
11
  const React = require("react");
12
- const { theme, useI18n } = require("@meterbox/react");
12
+ const { theme, useI18n, useBaseUrl } = require("@meterbox/react");
13
13
 
14
14
  const REASONS = {
15
15
  too_expensive: "It's too expensive",
@@ -58,7 +58,7 @@ function button(label, onClick, extra = {}, disabled = false) {
58
58
  }
59
59
 
60
60
  function CancelSubscription({
61
- baseUrl,
61
+ baseUrl: baseUrlProp,
62
62
  customerId,
63
63
  customerToken,
64
64
  fetch: fetchImpl,
@@ -67,6 +67,7 @@ function CancelSubscription({
67
67
  initialStep = "idle",
68
68
  onChange,
69
69
  }) {
70
+ const baseUrl = useBaseUrl(baseUrlProp);
70
71
  const { t, date } = useI18n();
71
72
  // idle → reason → offers → done
72
73
  const [step, setStep] = React.useState(initialStep === "reason" ? "reason" : "idle");
@@ -2,7 +2,6 @@
2
2
  * <CustomerPortal /> — drop-in multi-page portal.
3
3
  *
4
4
  * <CustomerPortal
5
- * baseUrl="https://meterbox.ai"
6
5
  * customerId="cus_42"
7
6
  * customerToken={jwt}
8
7
  * initialPage="account" // "account" (default) | "plans" | "credits"
@@ -39,7 +38,14 @@
39
38
  */
40
39
 
41
40
  const React = require("react");
42
- const { BrandingProvider, LocaleProvider, useI18n, logoUrl, theme } = require("@meterbox/react");
41
+ const {
42
+ BrandingProvider,
43
+ LocaleProvider,
44
+ useI18n,
45
+ useBaseUrl,
46
+ logoUrl,
47
+ theme,
48
+ } = require("@meterbox/react");
43
49
  const AccountPage = require("./pages/AccountPage");
44
50
  const PlansPage = require("./pages/PlansPage");
45
51
  const CreditsPage = require("./pages/CreditsPage");
@@ -116,7 +122,7 @@ function Tabs({ page, go }) {
116
122
  }
117
123
 
118
124
  function CustomerPortal({
119
- baseUrl,
125
+ baseUrl: baseUrlProp,
120
126
  customerId,
121
127
  customerToken,
122
128
  initialPage = "account",
@@ -132,6 +138,7 @@ function CustomerPortal({
132
138
  branding,
133
139
  fetch: fetchImpl,
134
140
  }) {
141
+ const baseUrl = useBaseUrl(baseUrlProp);
135
142
  const actionType = ACTION_PAGES[initialAction?.type] ? initialAction.type : null;
136
143
  const actionPlanId = initialAction?.planId || null;
137
144
  const [action, setAction] = React.useState(actionType);
@@ -8,7 +8,13 @@
8
8
  */
9
9
 
10
10
  const React = require("react");
11
- const { InvoiceHistory, BillingDetailsButton, theme, useI18n } = require("@meterbox/react");
11
+ const {
12
+ InvoiceHistory,
13
+ BillingDetailsButton,
14
+ theme,
15
+ useI18n,
16
+ useBaseUrl,
17
+ } = require("@meterbox/react");
12
18
  const CancelSubscription = require("../CancelSubscription");
13
19
 
14
20
  const styles = {
@@ -55,7 +61,8 @@ async function fetchMe({ baseUrl, customerId, customerToken, fetchImpl }) {
55
61
  return json;
56
62
  }
57
63
 
58
- function AccountPage({ baseUrl, customerId, customerToken, startCancel, fetch: fetchImpl }) {
64
+ function AccountPage({ baseUrl: baseUrlProp, customerId, customerToken, startCancel, fetch: fetchImpl }) {
65
+ const baseUrl = useBaseUrl(baseUrlProp);
59
66
  const { t, date } = useI18n();
60
67
  const [me, setMe] = React.useState(null);
61
68
  const [error, setError] = React.useState(null);
@@ -22,7 +22,7 @@
22
22
  */
23
23
 
24
24
  const React = require("react");
25
- const { PricingTable, PlanChangeCard, useI18n } = require("@meterbox/react");
25
+ const { PricingTable, PlanChangeCard, useI18n, useBaseUrl } = require("@meterbox/react");
26
26
 
27
27
  const styles = {
28
28
  wrap: { display: "grid", gap: 16 },
@@ -40,7 +40,7 @@ async function fetchJson(url, headers, fetchImpl) {
40
40
  }
41
41
 
42
42
  function PlansPage({
43
- baseUrl,
43
+ baseUrl: baseUrlProp,
44
44
  customerId,
45
45
  customerToken,
46
46
  currency = "USD",
@@ -50,7 +50,7 @@ function PlansPage({
50
50
  }) {
51
51
  const { t } = useI18n();
52
52
  const fetcher = fetchImpl || globalThis.fetch;
53
- const root = String(baseUrl).replace(/\/+$/, "");
53
+ const root = useBaseUrl(baseUrlProp);
54
54
  const [plans, setPlans] = React.useState(null);
55
55
  const [currentPlanId, setCurrentPlanId] = React.useState(null);
56
56
  const [scheduledChange, setScheduledChange] = React.useState(null);
@@ -146,7 +146,7 @@ function PlansPage({
146
146
  (pickedInterval === "annual"
147
147
  ? React.createElement("p", { style: { fontSize: 13, opacity: 0.7 } }, t("plans.annualNote"))
148
148
  : React.createElement(PlanChangeCard, {
149
- baseUrl,
149
+ baseUrl: root,
150
150
  customerId,
151
151
  customerToken,
152
152
  planId: picked,