@growth-operations/ui-shared 1.0.4 → 1.0.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/billing/BillingTab.jsx +22 -3
- package/src/sdk/app/settings.js +10 -2
package/package.json
CHANGED
|
@@ -34,10 +34,12 @@ function StatusPanel({ entitlement }) {
|
|
|
34
34
|
if (!entitlement) return null;
|
|
35
35
|
const {
|
|
36
36
|
status,
|
|
37
|
+
mode,
|
|
37
38
|
current_period_end,
|
|
38
39
|
trial_ends_at,
|
|
39
40
|
sandbox_trial_expires_at,
|
|
40
41
|
cancel_at_period_end,
|
|
42
|
+
has_payment_method,
|
|
41
43
|
} = entitlement;
|
|
42
44
|
|
|
43
45
|
// HubSpot's Alert renders `title` beside the body in a narrow column, which
|
|
@@ -53,13 +55,26 @@ function StatusPanel({ entitlement }) {
|
|
|
53
55
|
: left <= 0
|
|
54
56
|
? "Your free trial ends today"
|
|
55
57
|
: `${left} day${left === 1 ? "" : "s"} left in your free trial`;
|
|
58
|
+
// What (if anything) the customer must do before the trial ends, by mode:
|
|
59
|
+
// - credits: pick/buy a credit plan to continue.
|
|
60
|
+
// - trial_subscription (plan already chosen — toast): the trial just needs
|
|
61
|
+
// a payment method. If one's already on file it auto-converts (nothing to
|
|
62
|
+
// do); if not, they must add one or Stripe cancels at trial end.
|
|
63
|
+
// has_payment_method may be null (unknown) — then give the safe ask.
|
|
64
|
+
const trialCta =
|
|
65
|
+
mode === "credits"
|
|
66
|
+
? "Choose a plan in Stripe before then to keep going."
|
|
67
|
+
: has_payment_method === true
|
|
68
|
+
? "Your payment method is on file, so it converts automatically — nothing to do."
|
|
69
|
+
: has_payment_method === false
|
|
70
|
+
? "Add a payment method in Stripe before then, or your subscription will be canceled."
|
|
71
|
+
: "Add a payment method in Stripe before then so your subscription continues.";
|
|
56
72
|
return (
|
|
57
73
|
<Alert variant="warning">
|
|
58
74
|
<Flex direction="column" gap="extra-small">
|
|
59
75
|
<Text format={{ fontWeight: "bold" }}>{leftLabel}</Text>
|
|
60
76
|
<Text>
|
|
61
|
-
Trial ends {fmtDate(trialEnd)}.
|
|
62
|
-
keep syncing.
|
|
77
|
+
Trial ends {fmtDate(trialEnd)}. {trialCta}
|
|
63
78
|
</Text>
|
|
64
79
|
</Flex>
|
|
65
80
|
</Alert>
|
|
@@ -102,11 +117,15 @@ function StatusPanel({ entitlement }) {
|
|
|
102
117
|
}
|
|
103
118
|
|
|
104
119
|
if (status === "pending_purchase") {
|
|
120
|
+
const resumeCta =
|
|
121
|
+
mode === "credits"
|
|
122
|
+
? "Choose a plan in Stripe to resume."
|
|
123
|
+
: "Add a payment method in Stripe to resume syncing your data.";
|
|
105
124
|
return (
|
|
106
125
|
<Alert variant="warning">
|
|
107
126
|
<Flex direction="column" gap="extra-small">
|
|
108
127
|
<Text format={{ fontWeight: "bold" }}>Your free trial has ended</Text>
|
|
109
|
-
<Text>
|
|
128
|
+
<Text>{resumeCta}</Text>
|
|
110
129
|
</Flex>
|
|
111
130
|
</Alert>
|
|
112
131
|
);
|
package/src/sdk/app/settings.js
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
// shared with other importers.
|
|
9
9
|
//
|
|
10
10
|
// getSettings accepts { force } to bypass the cache (e.g. polling for live sync
|
|
11
|
-
// status, which a stale cache would otherwise mask).
|
|
11
|
+
// status, which a stale cache would otherwise mask). `force` bypasses BOTH the
|
|
12
|
+
// frontend module cache AND the backend account cache: it appends ?fresh=1 so a
|
|
13
|
+
// backend that honors it (e.g. toast's CacheableMixin-backed /settings) reads
|
|
14
|
+
// live state instead of its own ~120s-cached copy. updateSettings invalidates
|
|
12
15
|
// the cache on write.
|
|
13
16
|
//
|
|
14
17
|
// All requests go through callAppApi → hubspot.fetch rules apply (object body,
|
|
@@ -33,9 +36,14 @@ export function makeSettingsApi({ path = "/api/v1/settings" } = {}) {
|
|
|
33
36
|
return settingsPromise;
|
|
34
37
|
}
|
|
35
38
|
|
|
39
|
+
// On a forced read, also ask the backend to bypass its own cache (?fresh=1)
|
|
40
|
+
// so we don't just re-fetch a server-side-stale copy.
|
|
41
|
+
const reqPath = force
|
|
42
|
+
? `${path}${path.includes("?") ? "&" : "?"}fresh=1`
|
|
43
|
+
: path;
|
|
36
44
|
const fetchPromise = (async () => {
|
|
37
45
|
try {
|
|
38
|
-
const settings = await callAppApi(context,
|
|
46
|
+
const settings = await callAppApi(context, reqPath, "GET");
|
|
39
47
|
cachedSettings = settings;
|
|
40
48
|
settingsPromise = null;
|
|
41
49
|
return settings;
|