@lukoweb/apitogo-plugin-dev-portal-billing 0.2.52 → 0.2.53
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.
|
@@ -55,42 +55,6 @@ function useCancelSubscription() {
|
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/hooks/useChangePlan.ts
|
|
60
|
-
function useChangePlan() {
|
|
61
|
-
const apiBaseUrl = useDevPortalApiBaseUrl();
|
|
62
|
-
const queryClient = useQueryClient();
|
|
63
|
-
return useMutation({
|
|
64
|
-
mutationFn: async ({ fromPlanSku, toPlanSku }) => {
|
|
65
|
-
if (!apiBaseUrl) throw new Error("Dev portal API is not configured.");
|
|
66
|
-
const response = await fetch(`${apiBaseUrl}/api/v1/subscriptions/change`, {
|
|
67
|
-
method: "POST",
|
|
68
|
-
headers: {
|
|
69
|
-
Accept: "application/json",
|
|
70
|
-
"Content-Type": "application/json"
|
|
71
|
-
},
|
|
72
|
-
credentials: "include",
|
|
73
|
-
body: JSON.stringify({
|
|
74
|
-
fromPlanSku,
|
|
75
|
-
toPlanSku
|
|
76
|
-
})
|
|
77
|
-
});
|
|
78
|
-
if (!response.ok) {
|
|
79
|
-
const detail = await response.text();
|
|
80
|
-
throw new Error(detail || "Failed to change plan.");
|
|
81
|
-
}
|
|
82
|
-
return await response.json();
|
|
83
|
-
},
|
|
84
|
-
onSuccess: async (result) => {
|
|
85
|
-
if (result.checkoutUrl) {
|
|
86
|
-
window.location.assign(result.checkoutUrl);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
await queryClient.invalidateQueries({ queryKey: ["dev-portal-me", apiBaseUrl] });
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
58
|
//#endregion
|
|
95
59
|
//#region src/pages/AccountPlansPage.tsx
|
|
96
60
|
var AccountPlansPage_exports = /* @__PURE__ */ __exportAll({ default: () => AccountPlansPage });
|
|
@@ -106,24 +70,8 @@ const AccountPlansPage = () => {
|
|
|
106
70
|
const isError = isPreview ? false : livePlans.isError;
|
|
107
71
|
const { data: me } = useMySubscriptions();
|
|
108
72
|
const cancelMutation = useCancelSubscription();
|
|
109
|
-
const changeMutation = useChangePlan();
|
|
110
73
|
const [cancelingSku, setCancelingSku] = useState(null);
|
|
111
|
-
const [switchingSku, setSwitchingSku] = useState(null);
|
|
112
74
|
const subscriptionBySku = new Map((me?.subscriptions ?? []).map((sub) => [sub.planSku, sub]));
|
|
113
|
-
const activePlanSkus = (me?.subscriptions ?? []).filter((sub) => isActiveSubscription(sub.status)).map((sub) => sub.planSku);
|
|
114
|
-
const currentPlanSku = activePlanSkus.length === 1 ? activePlanSkus[0] : null;
|
|
115
|
-
const handleSwitch = async (toPlanSku) => {
|
|
116
|
-
if (!currentPlanSku) return;
|
|
117
|
-
setSwitchingSku(toPlanSku);
|
|
118
|
-
try {
|
|
119
|
-
await changeMutation.mutateAsync({
|
|
120
|
-
fromPlanSku: currentPlanSku,
|
|
121
|
-
toPlanSku
|
|
122
|
-
});
|
|
123
|
-
} finally {
|
|
124
|
-
setSwitchingSku(null);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
75
|
const handleUnsubscribe = async (planSku) => {
|
|
128
76
|
setCancelingSku(planSku);
|
|
129
77
|
try {
|
|
@@ -150,7 +98,7 @@ const AccountPlansPage = () => {
|
|
|
150
98
|
}),
|
|
151
99
|
/* @__PURE__ */ jsx("p", {
|
|
152
100
|
className: "max-w-2xl text-muted-foreground",
|
|
153
|
-
children: "Compare plans
|
|
101
|
+
children: "Compare plans and manage your subscriptions. You can hold several plans at once, and each has its own API keys and limits."
|
|
154
102
|
}),
|
|
155
103
|
checkoutCancelled ? /* @__PURE__ */ jsx("p", {
|
|
156
104
|
className: "max-w-2xl text-sm text-muted-foreground",
|
|
@@ -167,10 +115,6 @@ const AccountPlansPage = () => {
|
|
|
167
115
|
className: "mb-6 rounded-xl border border-destructive/30 bg-destructive/10 p-4 text-sm text-destructive",
|
|
168
116
|
children: cancelMutation.error instanceof Error ? cancelMutation.error.message : "Failed to cancel subscription."
|
|
169
117
|
}) : null,
|
|
170
|
-
changeMutation.isError ? /* @__PURE__ */ jsx("div", {
|
|
171
|
-
className: "mb-6 rounded-xl border border-destructive/30 bg-destructive/10 p-4 text-sm text-destructive",
|
|
172
|
-
children: changeMutation.error instanceof Error ? changeMutation.error.message : "Failed to change plan."
|
|
173
|
-
}) : null,
|
|
174
118
|
isLoading ? /* @__PURE__ */ jsx("p", {
|
|
175
119
|
className: "text-muted-foreground",
|
|
176
120
|
children: "Loading plans…"
|
|
@@ -190,8 +134,6 @@ const AccountPlansPage = () => {
|
|
|
190
134
|
subscriptionStatus: subscription?.status,
|
|
191
135
|
isSubscribed,
|
|
192
136
|
onUnsubscribe: isPreview || isDemoSession ? void 0 : handleUnsubscribe,
|
|
193
|
-
onSwitch: currentPlanSku && !isPreview && !isDemoSession ? handleSwitch : void 0,
|
|
194
|
-
isSwitching: switchingSku === plan.sku,
|
|
195
137
|
isCanceling: cancelingSku === plan.sku,
|
|
196
138
|
cancelDisabled: isPreview || isDemoSession
|
|
197
139
|
}, plan.sku);
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as AccountPlansPage } from "./AccountPlansPage-
|
|
1
|
+
import { t as AccountPlansPage } from "./AccountPlansPage-DvRFe3di.mjs";
|
|
2
2
|
import { a as LOGIN_NAV_PATH, c as USAGE_PATH, i as CREDENTIALS_PATH, n as CHECKOUT_PATH, o as PRICING_PATH, r as CONTACT_SALES_PATH, s as SUBSCRIPTIONS_PATH, t as ACCOUNT_PLANS_PATH } from "./paths-ujy9wjVK.mjs";
|
|
3
3
|
import { d as listPlanFeatureLines, f as parseManifestPlans, h as pickFeaturedPlanSku, i as formatPlanDisplayPrice, o as formatPlanPriceUnit, s as isActiveSubscription, v as resolveDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-BstWzITX.mjs";
|
|
4
4
|
import "./PricingCard-CKdq1oWn.mjs";
|
|
@@ -366,7 +366,7 @@ async function getSignedInIdentities(apiBaseUrl, fetchImpl = fetch) {
|
|
|
366
366
|
|
|
367
367
|
//#endregion
|
|
368
368
|
//#region src/DevPortalBillingPlugin.tsx
|
|
369
|
-
const AccountPlansPage$1 = lazy(() => import("./AccountPlansPage-
|
|
369
|
+
const AccountPlansPage$1 = lazy(() => import("./AccountPlansPage-DvRFe3di.mjs").then((n) => n.n));
|
|
370
370
|
const CheckoutPage = lazy(() => import("./CheckoutPage-CwSElFUk.mjs"));
|
|
371
371
|
const ContactSalesPage = lazy(() => import("./ContactSalesPage-q7Dxxtx6.mjs"));
|
|
372
372
|
const CredentialsPage = lazy(() => import("./CredentialsPage-B2jPo6Go.mjs"));
|
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.53",
|
|
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.53",
|
|
50
|
+
"@lukoweb/apitogo-module-user-panel": "0.2.53"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"react": ">=19.2.0",
|