@robosystems/core 0.21.4 → 0.21.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.
|
@@ -23,6 +23,8 @@ export interface ActiveSubscriptionsProps {
|
|
|
23
23
|
onCancel?: (subscription: SubscriptionInfo) => void;
|
|
24
24
|
/** Fallback component to render when there are no active subscriptions */
|
|
25
25
|
emptyState?: React.ReactNode;
|
|
26
|
+
/** Shown under the page header, above the subscriptions (e.g. a trial notice) */
|
|
27
|
+
banner?: React.ReactNode;
|
|
26
28
|
}
|
|
27
|
-
export declare function ActiveSubscriptions({ onOpenConsole, onOpenUsage, onGettingStarted, onBackups, onBilling, onBrowse, onCancel, emptyState, }: ActiveSubscriptionsProps): import("react").JSX.Element;
|
|
29
|
+
export declare function ActiveSubscriptions({ onOpenConsole, onOpenUsage, onGettingStarted, onBackups, onBilling, onBrowse, onCancel, emptyState, banner, }: ActiveSubscriptionsProps): import("react").JSX.Element;
|
|
28
30
|
export {};
|
|
@@ -12,7 +12,7 @@ import { useUser } from '../../hooks/use-user';
|
|
|
12
12
|
import { unwrapSdk } from '../../lib/sdk-errors';
|
|
13
13
|
import { utcDate } from '../../lib/utc-date';
|
|
14
14
|
import { Badge, Button, Card, Spinner } from '../../ui';
|
|
15
|
-
export function ActiveSubscriptions({ onOpenConsole, onOpenUsage, onGettingStarted, onBackups, onBilling, onBrowse, onCancel, emptyState, }) {
|
|
15
|
+
export function ActiveSubscriptions({ onOpenConsole, onOpenUsage, onGettingStarted, onBackups, onBilling, onBrowse, onCancel, emptyState, banner, }) {
|
|
16
16
|
const [userSubscriptions, setUserSubscriptions] = useState([]);
|
|
17
17
|
const [loading, setLoading] = useState(true);
|
|
18
18
|
// A failed subscription read must not render as "no subscriptions": that
|
|
@@ -66,16 +66,17 @@ export function ActiveSubscriptions({ onOpenConsole, onOpenUsage, onGettingStart
|
|
|
66
66
|
if (loadError) {
|
|
67
67
|
return (_jsxs("div", { className: "space-y-6", children: [_jsx(ToastContainer, {}), _jsx(Card, { children: _jsxs("div", { className: "flex flex-col items-center gap-4 py-8 text-center", children: [_jsx("p", { className: "text-zinc-700 dark:text-zinc-300", children: loadError }), _jsx(Button, { color: "gray", onClick: () => loadData(), children: "Try again" })] }) })] }));
|
|
68
68
|
}
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
// promises continued access through current_period_end.
|
|
69
|
+
// A canceled sub stays listed until its access ends: `ends_at`, the period's
|
|
70
|
+
// end for a cancel at period end, the moment itself for one that ended at
|
|
71
|
+
// once (an immediate cancel, or one the payment provider ended).
|
|
73
72
|
const now = new Date();
|
|
74
73
|
const activeSubscriptions = userSubscriptions.filter((s) => {
|
|
74
|
+
var _a;
|
|
75
75
|
if (s.status === 'active')
|
|
76
76
|
return true;
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
const endsAt = (_a = s.ends_at) !== null && _a !== void 0 ? _a : s.current_period_end;
|
|
78
|
+
if (s.status === 'canceled' && endsAt) {
|
|
79
|
+
return utcDate(endsAt) > now;
|
|
79
80
|
}
|
|
80
81
|
return false;
|
|
81
82
|
});
|
|
@@ -109,7 +110,7 @@ export function ActiveSubscriptions({ onOpenConsole, onOpenUsage, onGettingStart
|
|
|
109
110
|
}
|
|
110
111
|
onBackups === null || onBackups === void 0 ? void 0 : onBackups(repositoryId);
|
|
111
112
|
};
|
|
112
|
-
return (_jsxs("div", { className: "space-y-6", children: [_jsx(ToastContainer, {}), _jsxs("div", { className: "flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-3 sm:gap-4", children: [_jsx("div", { className: "from-primary-500 to-secondary-600 shrink-0 rounded-lg bg-gradient-to-br p-2.5 sm:p-3", children: _jsx(HiGlobeAlt, { className: "h-6 w-6 text-white sm:h-8 sm:w-8" }) }), _jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "font-heading text-2xl font-bold break-words text-zinc-900 sm:text-3xl dark:text-zinc-100", children: "Repository Subscriptions" }), _jsx("p", { className: "mt-1 text-sm text-zinc-500 dark:text-zinc-400", children: "Browse shared public datasets" })] })] }), onBrowse && (_jsxs(Button, { onClick: onBrowse, color: "purple", children: [_jsx(HiGlobeAlt, { className: "mr-2 h-4 w-4" }), "Browse Repositories"] }))] }), activeSubscriptions.map((subscription) => {
|
|
113
|
+
return (_jsxs("div", { className: "space-y-6", children: [_jsx(ToastContainer, {}), _jsxs("div", { className: "flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-3 sm:gap-4", children: [_jsx("div", { className: "from-primary-500 to-secondary-600 shrink-0 rounded-lg bg-gradient-to-br p-2.5 sm:p-3", children: _jsx(HiGlobeAlt, { className: "h-6 w-6 text-white sm:h-8 sm:w-8" }) }), _jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "font-heading text-2xl font-bold break-words text-zinc-900 sm:text-3xl dark:text-zinc-100", children: "Repository Subscriptions" }), _jsx("p", { className: "mt-1 text-sm text-zinc-500 dark:text-zinc-400", children: "Browse shared public datasets" })] })] }), onBrowse && (_jsxs(Button, { onClick: onBrowse, color: "purple", children: [_jsx(HiGlobeAlt, { className: "mr-2 h-4 w-4" }), "Browse Repositories"] }))] }), banner, activeSubscriptions.map((subscription) => {
|
|
113
114
|
var _a, _b, _c;
|
|
114
115
|
const repoOffering = (_a = offerings === null || offerings === void 0 ? void 0 : offerings.repositoryPlans) === null || _a === void 0 ? void 0 : _a[subscription.resource_id];
|
|
115
116
|
const planFeatures = (_c = (_b = repoOffering === null || repoOffering === void 0 ? void 0 : repoOffering.plans) === null || _b === void 0 ? void 0 : _b.find((p) => p.plan.toLowerCase() === subscription.plan_name.toLowerCase())) === null || _c === void 0 ? void 0 : _c.features;
|
|
@@ -26,6 +26,9 @@ export function BrowseRepositories({ onSubscribed, onViewSubscriptions, showHead
|
|
|
26
26
|
const [changingPlan, setChangingPlan] = useState(false);
|
|
27
27
|
const [planChangeModal, setPlanChangeModal] = useState(null);
|
|
28
28
|
const { showSuccess, showError, ToastContainer } = useToast();
|
|
29
|
+
// A refused subscribe stays on the page: a toast fades before an
|
|
30
|
+
// unverified user has read where to verify.
|
|
31
|
+
const [subscribeError, setSubscribeError] = useState(null);
|
|
29
32
|
const { currentOrg } = useOrg();
|
|
30
33
|
const { user } = useUser();
|
|
31
34
|
const { offerings, isLoading: offeringsLoading } = useServiceOfferings();
|
|
@@ -82,6 +85,7 @@ export function BrowseRepositories({ onSubscribed, onViewSubscriptions, showHead
|
|
|
82
85
|
return;
|
|
83
86
|
}
|
|
84
87
|
try {
|
|
88
|
+
setSubscribeError(null);
|
|
85
89
|
setSubscribing(`${repositoryType}-${tier}`);
|
|
86
90
|
const result = await repositorySubscription.subscribe({
|
|
87
91
|
repository_name: repositoryType,
|
|
@@ -109,7 +113,7 @@ export function BrowseRepositories({ onSubscribed, onViewSubscriptions, showHead
|
|
|
109
113
|
}
|
|
110
114
|
catch (error) {
|
|
111
115
|
console.error('Failed to subscribe:', error);
|
|
112
|
-
|
|
116
|
+
setSubscribeError(error instanceof Error
|
|
113
117
|
? error.message
|
|
114
118
|
: 'Failed to subscribe to repository');
|
|
115
119
|
}
|
|
@@ -183,7 +187,7 @@ export function BrowseRepositories({ onSubscribed, onViewSubscriptions, showHead
|
|
|
183
187
|
const trialEndsAt = userSub === null || userSub === void 0 ? void 0 : userSub.trial_ends_at;
|
|
184
188
|
const onTrial = !!trialEndsAt && utcDate(trialEndsAt) > new Date();
|
|
185
189
|
return (_jsx(Card, { className: "overflow-hidden", children: _jsxs("div", { className: "space-y-6", children: [_jsxs("div", { className: "flex items-start justify-between", children: [_jsxs("div", { className: "flex items-start gap-4", children: [_jsx("div", { className: "from-primary-500 to-secondary-600 rounded-lg bg-gradient-to-br p-3", children: _jsx(GoRepo, { className: "h-8 w-8 text-white" }) }), _jsxs("div", { children: [_jsx("h2", { className: "font-heading text-2xl font-bold text-zinc-900 dark:text-zinc-100", children: repoData.name }), _jsx("p", { className: "mt-1 text-zinc-600 dark:text-zinc-400", children: repoData.description })] })] }), userSub && (_jsxs(Badge, { color: onTrial ? 'info' : 'success', icon: HiCheckCircle, size: "lg", children: [onTrial ? 'Free trial' : 'Active', " -", ' ', userSub.plan_name.charAt(0).toUpperCase() +
|
|
186
|
-
userSub.plan_name.slice(1)] }))] }), trialDays > 0 && (_jsx(Alert, { color: "info", icon: HiInformationCircle, children: _jsxs("p", { className: "text-sm", children: [_jsxs("span", { className: "font-semibold", children: ["Start with a ", trialDays, "-day free trial on either plan."] }), ' ', "The trial opens the analysis tools over MCP and the API, at lower rate limits than the plan. Raw Cypher queries, the AI analyst and your monthly credits open with the first payment. No card is needed to start: add one before the trial ends and your plan starts when it does, or start it sooner from your organization's Subscriptions tab. Without a card the trial ends and nothing is charged."] }) })), _jsx("div", { className: `grid gap-6 ${repoData.plans.length === 2
|
|
190
|
+
userSub.plan_name.slice(1)] }))] }), trialDays > 0 && (_jsx(Alert, { color: "info", icon: HiInformationCircle, children: _jsxs("p", { className: "text-sm", children: [_jsxs("span", { className: "font-semibold", children: ["Start with a ", trialDays, "-day free trial on either plan."] }), ' ', "The trial opens the analysis tools over MCP and the API, at lower rate limits than the plan. Raw Cypher queries, the AI analyst and your monthly credits open with the first payment. No card is needed to start: add one before the trial ends and your plan starts when it does, or start it sooner from your organization's Subscriptions tab. Without a card the trial ends and nothing is charged."] }) })), subscribeError && (_jsxs(Alert, { color: "failure", onDismiss: () => setSubscribeError(null), "data-testid": "subscribe-error", children: [_jsx("p", { className: "text-sm", children: subscribeError }), /^verify your email/i.test(subscribeError) && (_jsx("a", { href: "/settings", className: "mt-2 inline-block text-sm font-medium underline underline-offset-4", children: "Send a new verification email" }))] })), _jsx("div", { className: `grid gap-6 ${repoData.plans.length === 2
|
|
187
191
|
? 'mx-auto max-w-3xl lg:grid-cols-2'
|
|
188
192
|
: 'lg:grid-cols-3'}`, children: repoData.plans.map((plan, index) => {
|
|
189
193
|
var _a, _b;
|