@growth-operations/ui-shared 1.0.5 → 1.0.7
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/index.js +13 -0
- package/src/lib/urls.js +53 -0
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/index.js
CHANGED
|
@@ -27,6 +27,19 @@ export {
|
|
|
27
27
|
} from "./lib/format";
|
|
28
28
|
export { useStrictModeEffect } from "./lib/useStrictModeEffect";
|
|
29
29
|
|
|
30
|
+
// HubSpot URL builders (app.hubspot.com record/property/list links).
|
|
31
|
+
export {
|
|
32
|
+
buildContactUrl,
|
|
33
|
+
buildRecordUrl,
|
|
34
|
+
buildObjectListUrl,
|
|
35
|
+
buildContactListCreateUrl,
|
|
36
|
+
buildContactListEditUrl,
|
|
37
|
+
buildFormEditorUrl,
|
|
38
|
+
buildPropertySettingsUrl,
|
|
39
|
+
buildPropertyName,
|
|
40
|
+
buildPropertyNames,
|
|
41
|
+
} from "./lib/urls";
|
|
42
|
+
|
|
30
43
|
// SDK — the token + API utility layer (see README "SDK" section and src/sdk/).
|
|
31
44
|
export {
|
|
32
45
|
// App backend
|
package/src/lib/urls.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Shared HubSpot URL builders for Growth Operations app UIs.
|
|
2
|
+
// Framework-agnostic (no React) — every app links out to HubSpot records,
|
|
3
|
+
// properties, and lists from the same app.hubspot.com URL shapes, so these are
|
|
4
|
+
// generic. Centralized here so a HubSpot URL-format change is fixed once.
|
|
5
|
+
|
|
6
|
+
const APP = "https://app.hubspot.com";
|
|
7
|
+
|
|
8
|
+
// A contact record. (Contacts are object type 0-1; see buildRecordUrl for the
|
|
9
|
+
// generic form.)
|
|
10
|
+
export function buildContactUrl(portalId, contactId) {
|
|
11
|
+
return `${APP}/contacts/${portalId}/contact/${contactId}`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Any CRM record by object type id (e.g. "0-1" contacts, a custom object id).
|
|
15
|
+
export function buildRecordUrl(portalId, objectTypeId, recordId) {
|
|
16
|
+
return `${APP}/contacts/${portalId}/record/${objectTypeId}/${recordId}`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// A custom object's "all records" list view.
|
|
20
|
+
export function buildObjectListUrl(portalId, objectTypeId) {
|
|
21
|
+
return `${APP}/contacts/${portalId}/objects/${objectTypeId}/views/all/list`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// The contact-list creation screen.
|
|
25
|
+
export function buildContactListCreateUrl(portalId) {
|
|
26
|
+
return `${APP}/contacts/${portalId}/objectLists/create`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// A specific contact list's filter editor.
|
|
30
|
+
export function buildContactListEditUrl(portalId, listId) {
|
|
31
|
+
return `${APP}/contacts/${portalId}/objectLists/${listId}/filters`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// A form's editor.
|
|
35
|
+
export function buildFormEditorUrl(portalId, formId) {
|
|
36
|
+
return `${APP}/forms/${portalId}/editor/${formId}/edit/form`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// A property's settings/edit screen. objectTypeId defaults to contacts ("0-1").
|
|
40
|
+
export function buildPropertySettingsUrl(portalId, propertyName, objectTypeId = "0-1") {
|
|
41
|
+
return `${APP}/property-settings/${portalId}/properties?type=${objectTypeId}&action=edit&property=${propertyName}`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Prefix a property name with an app prefix (e.g. "a12005537"). No-op without a
|
|
45
|
+
// prefix. Useful when reading/writing app-namespaced custom properties.
|
|
46
|
+
export function buildPropertyName(appPrefix, propertyName) {
|
|
47
|
+
if (!appPrefix) return propertyName;
|
|
48
|
+
return `${appPrefix}_${propertyName}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function buildPropertyNames(appPrefix, propertyNames = []) {
|
|
52
|
+
return propertyNames.map((name) => buildPropertyName(appPrefix, name));
|
|
53
|
+
}
|