@lukoweb/apitogo-plugin-dev-portal-billing 0.2.29 → 0.2.31
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/dist/index.mjs +34 -10
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Button, Head, Heading, Link, Spinner } from "@lukoweb/apitogo/components";
|
|
2
2
|
import { ArrowRightIcon, CreditCardIcon, KeyRoundIcon, ShieldIcon, StarsIcon, TrashIcon } from "@lukoweb/apitogo/icons";
|
|
3
|
-
import { createContext, useContext, useEffect, useState } from "react";
|
|
4
3
|
import { Link as Link$1, Navigate, Outlet, useNavigate, useSearchParams } from "@lukoweb/apitogo/router";
|
|
4
|
+
import { createContext, useContext, useEffect, useState } from "react";
|
|
5
5
|
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from "@lukoweb/apitogo/ui/AlertDialog.js";
|
|
6
6
|
import { cn } from "@lukoweb/apitogo/ui/util.js";
|
|
7
7
|
import manifestCatalog from "virtual:apitogo-local-manifest";
|
|
@@ -584,6 +584,8 @@ function usePlans() {
|
|
|
584
584
|
//#endregion
|
|
585
585
|
//#region src/pages/AccountPlansPage.tsx
|
|
586
586
|
const AccountPlansPage = () => {
|
|
587
|
+
const [searchParams] = useSearchParams();
|
|
588
|
+
const checkoutCancelled = searchParams.get("checkout") === "cancelled";
|
|
587
589
|
const { previewPlans } = useDevPortalBillingConfig();
|
|
588
590
|
const isPreview = useDevPortalPreviewMode();
|
|
589
591
|
const isDemoSession = useIsDemoSession();
|
|
@@ -630,13 +632,20 @@ const AccountPlansPage = () => {
|
|
|
630
632
|
children: /* @__PURE__ */ jsx(CreditCardIcon, { size: 24 })
|
|
631
633
|
}), /* @__PURE__ */ jsxs("div", {
|
|
632
634
|
className: "space-y-1",
|
|
633
|
-
children: [
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
635
|
+
children: [
|
|
636
|
+
/* @__PURE__ */ jsx("h1", {
|
|
637
|
+
className: "text-3xl font-semibold tracking-tight",
|
|
638
|
+
children: "Plans & billing"
|
|
639
|
+
}),
|
|
640
|
+
/* @__PURE__ */ jsx("p", {
|
|
641
|
+
className: "max-w-2xl text-muted-foreground",
|
|
642
|
+
children: "Compare plans, manage your subscriptions, and change tiers."
|
|
643
|
+
}),
|
|
644
|
+
checkoutCancelled ? /* @__PURE__ */ jsx("p", {
|
|
645
|
+
className: "max-w-2xl text-sm text-muted-foreground",
|
|
646
|
+
children: "Checkout was cancelled and you were not charged."
|
|
647
|
+
}) : null
|
|
648
|
+
]
|
|
640
649
|
})]
|
|
641
650
|
}),
|
|
642
651
|
isDemoSession ? /* @__PURE__ */ jsx("div", {
|
|
@@ -2156,7 +2165,7 @@ const SubscriptionsPage = () => {
|
|
|
2156
2165
|
const auth = useAuth();
|
|
2157
2166
|
const [searchParams] = useSearchParams();
|
|
2158
2167
|
const checkoutSuccess = searchParams.get("checkout") === "success";
|
|
2159
|
-
const { data: me, isLoading } = useMySubscriptions();
|
|
2168
|
+
const { data: me, isLoading, refetch } = useMySubscriptions();
|
|
2160
2169
|
const { data: catalog } = usePlans();
|
|
2161
2170
|
const billingPortal = useBillingPortal();
|
|
2162
2171
|
const { data: usage } = useUsage("mtd");
|
|
@@ -2164,6 +2173,17 @@ const SubscriptionsPage = () => {
|
|
|
2164
2173
|
const subscriptions = me?.subscriptions ?? [];
|
|
2165
2174
|
const activeSubscription = subscriptions.find((sub) => isActiveSubscription(sub.status));
|
|
2166
2175
|
const activePlan = activeSubscription ? planBySku.get(activeSubscription.planSku) : void 0;
|
|
2176
|
+
const confirmingPayment = checkoutSuccess && !isLoading && !activeSubscription;
|
|
2177
|
+
useEffect(() => {
|
|
2178
|
+
if (!confirmingPayment) return;
|
|
2179
|
+
let attempts = 0;
|
|
2180
|
+
const timer = setInterval(() => {
|
|
2181
|
+
attempts += 1;
|
|
2182
|
+
refetch();
|
|
2183
|
+
if (attempts >= 30) clearInterval(timer);
|
|
2184
|
+
}, 2e3);
|
|
2185
|
+
return () => clearInterval(timer);
|
|
2186
|
+
}, [confirmingPayment, refetch]);
|
|
2167
2187
|
const monthlyQuota = activePlan ? parseMonthlyQuotaCalls(activePlan.limitsJson) : null;
|
|
2168
2188
|
const usedRequests = usage?.requestCount ?? 0;
|
|
2169
2189
|
const quotaPct = monthlyQuota && monthlyQuota > 0 ? Math.min(100, Math.round(usedRequests / monthlyQuota * 100)) : null;
|
|
@@ -2179,7 +2199,11 @@ const SubscriptionsPage = () => {
|
|
|
2179
2199
|
className: "mb-8 text-muted-foreground",
|
|
2180
2200
|
children: "Manage your plan, payment method, and invoices."
|
|
2181
2201
|
}),
|
|
2182
|
-
|
|
2202
|
+
confirmingPayment ? /* @__PURE__ */ jsx("div", {
|
|
2203
|
+
className: "mb-6 rounded-xl border border-border bg-card p-4 text-sm",
|
|
2204
|
+
children: "Payment received. Confirming your subscription, this takes a few seconds…"
|
|
2205
|
+
}) : null,
|
|
2206
|
+
checkoutSuccess && activeSubscription ? /* @__PURE__ */ jsxs("div", {
|
|
2183
2207
|
className: "mb-6 rounded-xl border border-green-500/30 bg-green-500/10 p-4 text-sm",
|
|
2184
2208
|
children: [
|
|
2185
2209
|
"Your subscription is active.",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lukoweb/apitogo-plugin-dev-portal-billing",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.31",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/zuplo/zudoku",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"react": "19.2.4",
|
|
47
47
|
"react-dom": "19.2.4",
|
|
48
48
|
"tsdown": "0.20.3",
|
|
49
|
-
"@lukoweb/apitogo": "0.2.
|
|
50
|
-
"@lukoweb/apitogo-module-user-panel": "0.2.
|
|
49
|
+
"@lukoweb/apitogo": "0.2.31",
|
|
50
|
+
"@lukoweb/apitogo-module-user-panel": "0.2.31"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"react": ">=19.2.0",
|