@sudobility/subscription_pages 0.0.10 → 0.0.13
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.
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SubscriptionPlatform } from '@sudobility/types';
|
|
2
|
+
import { BackendSubscriptionResult } from '@sudobility/subscription_lib';
|
|
3
|
+
export interface CrossPlatformSubscriptionInfoProps {
|
|
4
|
+
backendSubscription: BackendSubscriptionResult;
|
|
5
|
+
managementUrl?: string;
|
|
6
|
+
currentPlatform: SubscriptionPlatform;
|
|
7
|
+
}
|
|
8
|
+
export declare function CrossPlatformSubscriptionInfo({ backendSubscription, managementUrl, }: CrossPlatformSubscriptionInfoProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -1,93 +1,162 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useState as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { jsxs as m, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useState as C, useEffect as ke } from "react";
|
|
3
|
+
import { SubscriptionPlatform as se } from "@sudobility/types";
|
|
4
|
+
import { usePackagesByDuration as xe, useUserSubscription as le, useBackendSubscription as de, getSubscriptionInstance as ue, refreshSubscription as pe, useAllOfferings as Ce, useOfferingPackages as Pe, periodToMonths as ie } from "@sudobility/subscription_lib";
|
|
5
|
+
import { SubscriptionLayout as P, SubscriptionTile as Ie, SegmentedControl as fe } from "@sudobility/subscription-components";
|
|
6
|
+
const Ae = {
|
|
7
|
+
web: "Web",
|
|
8
|
+
ios: "iOS",
|
|
9
|
+
android: "Android",
|
|
10
|
+
macos: "macOS"
|
|
11
|
+
};
|
|
12
|
+
function ge({
|
|
13
|
+
backendSubscription: n,
|
|
14
|
+
managementUrl: c
|
|
15
|
+
}) {
|
|
16
|
+
const i = n.platform ? Ae[n.platform] ?? n.platform : "another platform";
|
|
17
|
+
return /* @__PURE__ */ m("div", { className: "col-span-full rounded-xl border border-amber-200 dark:border-amber-700 bg-amber-50 dark:bg-amber-900/20 p-6 text-center space-y-4", children: [
|
|
18
|
+
/* @__PURE__ */ a("h3", { className: "text-lg font-semibold text-gray-900 dark:text-gray-100", children: "Subscription Active" }),
|
|
19
|
+
/* @__PURE__ */ m("div", { className: "space-y-2 text-sm text-gray-700 dark:text-gray-300", children: [
|
|
20
|
+
/* @__PURE__ */ m("p", { children: [
|
|
21
|
+
"Entitlements:",
|
|
22
|
+
" ",
|
|
23
|
+
/* @__PURE__ */ a("span", { className: "font-medium", children: n.entitlements.join(", ") })
|
|
24
|
+
] }),
|
|
25
|
+
n.subscriptionStartedAt && /* @__PURE__ */ m("p", { children: [
|
|
26
|
+
"Subscribed since:",
|
|
27
|
+
" ",
|
|
28
|
+
/* @__PURE__ */ a("span", { className: "font-medium", children: new Date(
|
|
29
|
+
n.subscriptionStartedAt
|
|
30
|
+
).toLocaleDateString() })
|
|
31
|
+
] })
|
|
32
|
+
] }),
|
|
33
|
+
/* @__PURE__ */ m("p", { className: "text-sm text-amber-800 dark:text-amber-300", children: [
|
|
34
|
+
"Your subscription was purchased on",
|
|
35
|
+
" ",
|
|
36
|
+
/* @__PURE__ */ a("span", { className: "font-semibold", children: i }),
|
|
37
|
+
". To manage your subscription, please visit your ",
|
|
38
|
+
i,
|
|
39
|
+
" settings."
|
|
40
|
+
] }),
|
|
41
|
+
c && /* @__PURE__ */ a(
|
|
42
|
+
"a",
|
|
43
|
+
{
|
|
44
|
+
href: c,
|
|
45
|
+
target: "_blank",
|
|
46
|
+
rel: "noopener noreferrer",
|
|
47
|
+
className: "inline-block rounded-lg px-5 py-2.5 text-sm font-semibold bg-blue-600 text-white hover:bg-blue-700 transition-colors",
|
|
48
|
+
children: "Manage Subscription"
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
|
+
] });
|
|
52
|
+
}
|
|
53
|
+
function $e({
|
|
6
54
|
isLoggedIn: n,
|
|
7
|
-
onNavigateToLogin:
|
|
8
|
-
userId:
|
|
9
|
-
userEmail:
|
|
10
|
-
featuresByPackage:
|
|
11
|
-
freeFeatures:
|
|
12
|
-
title:
|
|
13
|
-
className:
|
|
55
|
+
onNavigateToLogin: c,
|
|
56
|
+
userId: i,
|
|
57
|
+
userEmail: l,
|
|
58
|
+
featuresByPackage: b,
|
|
59
|
+
freeFeatures: u,
|
|
60
|
+
title: d = "Choose Your Plan",
|
|
61
|
+
className: v,
|
|
62
|
+
currentPlatform: I = se.Web,
|
|
63
|
+
networkClient: A,
|
|
64
|
+
baseUrl: w,
|
|
65
|
+
token: E,
|
|
66
|
+
testMode: _
|
|
14
67
|
}) {
|
|
68
|
+
var O;
|
|
15
69
|
const {
|
|
16
|
-
packagesByDuration:
|
|
17
|
-
availableDurations:
|
|
18
|
-
isLoading:
|
|
19
|
-
error:
|
|
20
|
-
} =
|
|
70
|
+
packagesByDuration: M,
|
|
71
|
+
availableDurations: S,
|
|
72
|
+
isLoading: k,
|
|
73
|
+
error: h
|
|
74
|
+
} = xe(), {
|
|
21
75
|
subscription: r,
|
|
22
|
-
isLoading:
|
|
23
|
-
error:
|
|
24
|
-
} =
|
|
76
|
+
isLoading: j,
|
|
77
|
+
error: W
|
|
78
|
+
} = le({ userId: i, userEmail: l }), L = de(
|
|
79
|
+
A ?? {},
|
|
80
|
+
w ?? "",
|
|
81
|
+
E ?? "",
|
|
82
|
+
i ?? "",
|
|
83
|
+
{ testMode: _, enabled: !!(A && w && E && i) }
|
|
84
|
+
), B = ((O = L.data) == null ? void 0 : O.platform) ?? null, V = !B || B === I, [N, $] = C(null), [q, p] = C(null), [U, F] = C(!1), x = N ?? S[0] ?? null, z = k || j, D = h || W, Q = async (t, f) => {
|
|
25
85
|
try {
|
|
26
|
-
|
|
86
|
+
F(!0), p(null), await ue().purchase({
|
|
27
87
|
packageId: t,
|
|
28
|
-
offeringId:
|
|
29
|
-
customerEmail:
|
|
30
|
-
}), await
|
|
31
|
-
} catch (
|
|
32
|
-
|
|
33
|
-
|
|
88
|
+
offeringId: f,
|
|
89
|
+
customerEmail: l
|
|
90
|
+
}), await pe();
|
|
91
|
+
} catch (g) {
|
|
92
|
+
p(
|
|
93
|
+
g instanceof Error ? g.message : "Purchase failed"
|
|
34
94
|
);
|
|
35
95
|
} finally {
|
|
36
|
-
|
|
96
|
+
F(!1);
|
|
37
97
|
}
|
|
38
|
-
},
|
|
98
|
+
}, G = () => n ? (r == null ? void 0 : r.isActive) && r.packageId ? {
|
|
39
99
|
title: "Free",
|
|
40
100
|
price: "$0",
|
|
41
|
-
features:
|
|
42
|
-
ctaButton: {
|
|
43
|
-
label: "Cancel Subscription",
|
|
44
|
-
onClick: () => {
|
|
45
|
-
r.managementUrl && window.open(r.managementUrl, "_blank");
|
|
46
|
-
}
|
|
47
|
-
}
|
|
101
|
+
features: u ?? []
|
|
48
102
|
} : {
|
|
49
103
|
title: "Free",
|
|
50
104
|
price: "$0",
|
|
51
|
-
features:
|
|
52
|
-
|
|
53
|
-
label: "Current Plan"
|
|
54
|
-
},
|
|
55
|
-
topBadge: { text: "Current Plan", color: "blue" }
|
|
105
|
+
features: u ?? [],
|
|
106
|
+
topBadge: { text: "Current", color: "blue" }
|
|
56
107
|
} : {
|
|
57
108
|
title: "Free",
|
|
58
109
|
price: "$0",
|
|
59
|
-
features:
|
|
110
|
+
features: u ?? [],
|
|
60
111
|
ctaButton: {
|
|
61
112
|
label: "Try it for Free",
|
|
62
|
-
onClick:
|
|
113
|
+
onClick: c
|
|
63
114
|
}
|
|
64
|
-
},
|
|
115
|
+
}, T = () => {
|
|
116
|
+
r != null && r.managementUrl && window.open(r.managementUrl, "_blank");
|
|
117
|
+
}, H = (t) => {
|
|
65
118
|
if (!n)
|
|
66
119
|
return {
|
|
67
120
|
label: "Log in to Continue",
|
|
68
|
-
onClick:
|
|
69
|
-
};
|
|
70
|
-
const m = (r == null ? void 0 : r.isActive) && r.packageId;
|
|
71
|
-
if ((r == null ? void 0 : r.packageId) !== t.package.packageId)
|
|
72
|
-
return m ? {
|
|
73
|
-
label: "Change Subscription",
|
|
74
|
-
onClick: () => E(t.package.packageId, t.offerId)
|
|
75
|
-
} : {
|
|
76
|
-
label: "Subscribe",
|
|
77
|
-
onClick: () => E(t.package.packageId, t.offerId)
|
|
121
|
+
onClick: c
|
|
78
122
|
};
|
|
123
|
+
const f = (r == null ? void 0 : r.isActive) && r.packageId, g = (r == null ? void 0 : r.packageId) === t.package.packageId;
|
|
124
|
+
return f ? {
|
|
125
|
+
label: g ? "Manage Subscription" : "Change Subscription",
|
|
126
|
+
onClick: T
|
|
127
|
+
} : {
|
|
128
|
+
label: "Subscribe",
|
|
129
|
+
onClick: () => Q(t.package.packageId, t.offerId)
|
|
130
|
+
};
|
|
79
131
|
};
|
|
80
|
-
if (
|
|
81
|
-
return /* @__PURE__ */
|
|
82
|
-
|
|
132
|
+
if (z)
|
|
133
|
+
return /* @__PURE__ */ a(
|
|
134
|
+
P,
|
|
135
|
+
{
|
|
136
|
+
title: d,
|
|
137
|
+
className: v,
|
|
138
|
+
variant: "cta",
|
|
139
|
+
children: /* @__PURE__ */ a("p", { children: "Loading subscription plans..." })
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
if (!V && L.data)
|
|
143
|
+
return /* @__PURE__ */ a(
|
|
144
|
+
P,
|
|
83
145
|
{
|
|
84
|
-
title:
|
|
85
|
-
className:
|
|
146
|
+
title: d,
|
|
147
|
+
className: v,
|
|
86
148
|
variant: "cta",
|
|
87
|
-
children: /* @__PURE__ */
|
|
149
|
+
children: /* @__PURE__ */ a(
|
|
150
|
+
ge,
|
|
151
|
+
{
|
|
152
|
+
backendSubscription: L.data,
|
|
153
|
+
managementUrl: r == null ? void 0 : r.managementUrl,
|
|
154
|
+
currentPlatform: I
|
|
155
|
+
}
|
|
156
|
+
)
|
|
88
157
|
}
|
|
89
158
|
);
|
|
90
|
-
const
|
|
159
|
+
const J = q ?? (D ? D.message : null), K = n && (r != null && r.isActive) && r.packageId ? {
|
|
91
160
|
isActive: !0,
|
|
92
161
|
activeContent: {
|
|
93
162
|
title: "Active Subscription",
|
|
@@ -107,44 +176,44 @@ function ve({
|
|
|
107
176
|
] : []
|
|
108
177
|
]
|
|
109
178
|
}
|
|
110
|
-
} : void 0,
|
|
111
|
-
return /* @__PURE__ */
|
|
112
|
-
|
|
179
|
+
} : void 0, R = x ? M[x] ?? [] : [];
|
|
180
|
+
return /* @__PURE__ */ a(
|
|
181
|
+
P,
|
|
113
182
|
{
|
|
114
|
-
title:
|
|
115
|
-
className:
|
|
183
|
+
title: d,
|
|
184
|
+
className: v,
|
|
116
185
|
variant: "cta",
|
|
117
|
-
error:
|
|
118
|
-
currentStatus:
|
|
119
|
-
freeTileConfig:
|
|
120
|
-
aboveProducts:
|
|
121
|
-
|
|
186
|
+
error: J,
|
|
187
|
+
currentStatus: K,
|
|
188
|
+
freeTileConfig: G(),
|
|
189
|
+
aboveProducts: S.length > 1 ? /* @__PURE__ */ a(
|
|
190
|
+
fe,
|
|
122
191
|
{
|
|
123
|
-
options:
|
|
192
|
+
options: S.map((t) => ({
|
|
124
193
|
value: t,
|
|
125
194
|
label: t.charAt(0).toUpperCase() + t.slice(1)
|
|
126
195
|
})),
|
|
127
|
-
value:
|
|
128
|
-
onChange: (t) =>
|
|
196
|
+
value: x ?? S[0],
|
|
197
|
+
onChange: (t) => $(t)
|
|
129
198
|
}
|
|
130
199
|
) : void 0,
|
|
131
|
-
children:
|
|
132
|
-
var
|
|
133
|
-
const
|
|
134
|
-
return /* @__PURE__ */
|
|
135
|
-
|
|
200
|
+
children: R.map((t) => {
|
|
201
|
+
var Y;
|
|
202
|
+
const f = n && (r == null ? void 0 : r.isActive) && r.packageId === t.package.packageId, g = H(t);
|
|
203
|
+
return /* @__PURE__ */ a(
|
|
204
|
+
Ie,
|
|
136
205
|
{
|
|
137
206
|
id: t.package.packageId,
|
|
138
207
|
title: t.package.name,
|
|
139
|
-
price: ((
|
|
208
|
+
price: ((Y = t.package.product) == null ? void 0 : Y.priceString) ?? "$0",
|
|
140
209
|
periodLabel: t.package.product ? `/${t.package.product.period}` : void 0,
|
|
141
|
-
features: (
|
|
210
|
+
features: (b == null ? void 0 : b[t.package.packageId]) ?? [],
|
|
142
211
|
isSelected: !1,
|
|
143
212
|
onSelect: () => {
|
|
144
213
|
},
|
|
145
|
-
isCurrentPlan:
|
|
146
|
-
ctaButton:
|
|
147
|
-
disabled:
|
|
214
|
+
isCurrentPlan: f,
|
|
215
|
+
ctaButton: g,
|
|
216
|
+
disabled: U
|
|
148
217
|
},
|
|
149
218
|
`${t.offerId}-${t.package.packageId}`
|
|
150
219
|
);
|
|
@@ -152,121 +221,138 @@ function ve({
|
|
|
152
221
|
}
|
|
153
222
|
);
|
|
154
223
|
}
|
|
155
|
-
function
|
|
224
|
+
function ce(n) {
|
|
156
225
|
return n.charAt(0).toUpperCase() + n.slice(1);
|
|
157
226
|
}
|
|
158
|
-
const
|
|
227
|
+
const we = {
|
|
159
228
|
weekly: "Weekly",
|
|
160
229
|
monthly: "Monthly",
|
|
161
230
|
quarterly: "Quarterly",
|
|
162
231
|
yearly: "Yearly",
|
|
163
232
|
lifetime: "Lifetime"
|
|
164
233
|
};
|
|
165
|
-
function
|
|
166
|
-
if (!n.product || !
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
169
|
-
const
|
|
170
|
-
if (
|
|
171
|
-
const
|
|
172
|
-
(
|
|
234
|
+
function Ee(n, c) {
|
|
235
|
+
if (!n.product || !c.product) return null;
|
|
236
|
+
const i = ie(n.product.period), l = ie(c.product.period);
|
|
237
|
+
if (i <= 0 || l <= 0 || i === 1 / 0 || l === 1 / 0 || i === l) return null;
|
|
238
|
+
const b = n.product.price / i, u = c.product.price / l;
|
|
239
|
+
if (b <= 0) return null;
|
|
240
|
+
const d = Math.round(
|
|
241
|
+
(b - u) / b * 100
|
|
173
242
|
);
|
|
174
|
-
return
|
|
243
|
+
return d > 0 ? d : null;
|
|
175
244
|
}
|
|
176
|
-
function
|
|
245
|
+
function Ue({
|
|
177
246
|
isLoggedIn: n,
|
|
178
|
-
onNavigateToLogin:
|
|
179
|
-
userId:
|
|
180
|
-
userEmail:
|
|
181
|
-
featuresByPackage:
|
|
182
|
-
freeFeatures:
|
|
183
|
-
title:
|
|
184
|
-
className:
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
247
|
+
onNavigateToLogin: c,
|
|
248
|
+
userId: i,
|
|
249
|
+
userEmail: l,
|
|
250
|
+
featuresByPackage: b,
|
|
251
|
+
freeFeatures: u,
|
|
252
|
+
title: d = "Choose Your Plan",
|
|
253
|
+
className: v,
|
|
254
|
+
currentPlatform: I = se.Web,
|
|
255
|
+
networkClient: A,
|
|
256
|
+
baseUrl: w,
|
|
257
|
+
token: E,
|
|
258
|
+
testMode: _,
|
|
259
|
+
t: M,
|
|
260
|
+
renderOfferingContent: S,
|
|
261
|
+
initialOfferId: k
|
|
188
262
|
}) {
|
|
189
|
-
var
|
|
190
|
-
const
|
|
263
|
+
var Z, ee;
|
|
264
|
+
const h = (o, s) => M ? M(o, s) : s, {
|
|
191
265
|
offerings: r,
|
|
192
|
-
isLoading:
|
|
193
|
-
error:
|
|
194
|
-
} =
|
|
266
|
+
isLoading: j,
|
|
267
|
+
error: W
|
|
268
|
+
} = Ce(), {
|
|
195
269
|
subscription: e,
|
|
196
|
-
isLoading:
|
|
197
|
-
error:
|
|
198
|
-
} =
|
|
199
|
-
|
|
270
|
+
isLoading: L,
|
|
271
|
+
error: B
|
|
272
|
+
} = le({ userId: i, userEmail: l }), N = de(
|
|
273
|
+
A ?? {},
|
|
274
|
+
w ?? "",
|
|
275
|
+
E ?? "",
|
|
276
|
+
i ?? "",
|
|
277
|
+
{ testMode: _, enabled: !!(A && w && E && i) }
|
|
278
|
+
), $ = ((Z = N.data) == null ? void 0 : Z.platform) ?? null, q = !$ || $ === I, [p, U] = C(
|
|
279
|
+
k ?? "free"
|
|
200
280
|
);
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}, [
|
|
204
|
-
const [
|
|
205
|
-
packages:
|
|
206
|
-
isLoading:
|
|
207
|
-
error:
|
|
208
|
-
} =
|
|
281
|
+
ke(() => {
|
|
282
|
+
k && U(k);
|
|
283
|
+
}, [k]);
|
|
284
|
+
const [F, x] = C(null), [z, D] = C(!1), Q = ((ee = r[0]) == null ? void 0 : ee.offerId) ?? "", G = p !== "free" ? p : Q, {
|
|
285
|
+
packages: T,
|
|
286
|
+
isLoading: H,
|
|
287
|
+
error: J
|
|
288
|
+
} = Pe(G), K = j || L || H, R = W || B || J, O = async (o, s) => {
|
|
209
289
|
try {
|
|
210
|
-
|
|
211
|
-
packageId:
|
|
212
|
-
offeringId:
|
|
213
|
-
customerEmail:
|
|
214
|
-
}), await
|
|
215
|
-
} catch (
|
|
216
|
-
|
|
217
|
-
|
|
290
|
+
D(!0), x(null), await ue().purchase({
|
|
291
|
+
packageId: o,
|
|
292
|
+
offeringId: s,
|
|
293
|
+
customerEmail: l
|
|
294
|
+
}), await pe();
|
|
295
|
+
} catch (y) {
|
|
296
|
+
x(
|
|
297
|
+
y instanceof Error ? y.message : "Purchase failed"
|
|
218
298
|
);
|
|
219
299
|
} finally {
|
|
220
|
-
|
|
300
|
+
D(!1);
|
|
221
301
|
}
|
|
222
|
-
},
|
|
223
|
-
{ value: "free", label:
|
|
224
|
-
...r.map((
|
|
225
|
-
value:
|
|
226
|
-
label:
|
|
302
|
+
}, t = [
|
|
303
|
+
{ value: "free", label: h("free", "Free") },
|
|
304
|
+
...r.map((o) => ({
|
|
305
|
+
value: o.offerId,
|
|
306
|
+
label: h(o.offerId, ce(o.offerId))
|
|
227
307
|
}))
|
|
228
|
-
],
|
|
229
|
-
title:
|
|
308
|
+
], f = T[0] ?? null, g = () => n ? (e == null ? void 0 : e.isActive) && e.packageId ? {
|
|
309
|
+
title: h("free", "Free"),
|
|
230
310
|
price: "$0",
|
|
231
|
-
features:
|
|
232
|
-
ctaButton: {
|
|
233
|
-
label: "Cancel Subscription",
|
|
234
|
-
onClick: () => {
|
|
235
|
-
e.managementUrl && window.open(e.managementUrl, "_blank");
|
|
236
|
-
}
|
|
237
|
-
}
|
|
311
|
+
features: u ?? []
|
|
238
312
|
} : {
|
|
239
|
-
title:
|
|
313
|
+
title: h("free", "Free"),
|
|
240
314
|
price: "$0",
|
|
241
|
-
features:
|
|
242
|
-
|
|
243
|
-
label: "Current Plan"
|
|
244
|
-
},
|
|
245
|
-
topBadge: { text: "Current Plan", color: "blue" }
|
|
315
|
+
features: u ?? [],
|
|
316
|
+
topBadge: { text: "Current", color: "blue" }
|
|
246
317
|
} : {
|
|
247
|
-
title:
|
|
318
|
+
title: h("free", "Free"),
|
|
248
319
|
price: "$0",
|
|
249
|
-
features:
|
|
320
|
+
features: u ?? [],
|
|
250
321
|
ctaButton: {
|
|
251
322
|
label: "Try it for Free",
|
|
252
|
-
onClick:
|
|
323
|
+
onClick: c
|
|
253
324
|
}
|
|
254
|
-
},
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
return /* @__PURE__ */ c(
|
|
261
|
-
$,
|
|
325
|
+
}, Y = () => {
|
|
326
|
+
e != null && e.managementUrl && window.open(e.managementUrl, "_blank");
|
|
327
|
+
}, me = (o) => n ? (e == null ? void 0 : e.isActive) && e.packageId ? (e == null ? void 0 : e.packageId) === o.packageId ? "Manage Subscription" : "Change Subscription" : "Subscribe" : "Log in to Continue", be = (o, s) => n ? (e == null ? void 0 : e.isActive) && e.packageId ? Y : () => O(o.packageId, s) : c;
|
|
328
|
+
if (K)
|
|
329
|
+
return /* @__PURE__ */ a(
|
|
330
|
+
P,
|
|
262
331
|
{
|
|
263
|
-
title:
|
|
264
|
-
className:
|
|
332
|
+
title: d,
|
|
333
|
+
className: v,
|
|
265
334
|
variant: "cta",
|
|
266
|
-
children: /* @__PURE__ */
|
|
335
|
+
children: /* @__PURE__ */ a("p", { children: "Loading subscription plans..." })
|
|
336
|
+
}
|
|
337
|
+
);
|
|
338
|
+
if (!q && N.data)
|
|
339
|
+
return /* @__PURE__ */ a(
|
|
340
|
+
P,
|
|
341
|
+
{
|
|
342
|
+
title: d,
|
|
343
|
+
className: v,
|
|
344
|
+
variant: "cta",
|
|
345
|
+
children: /* @__PURE__ */ a(
|
|
346
|
+
ge,
|
|
347
|
+
{
|
|
348
|
+
backendSubscription: N.data,
|
|
349
|
+
managementUrl: e == null ? void 0 : e.managementUrl,
|
|
350
|
+
currentPlatform: I
|
|
351
|
+
}
|
|
352
|
+
)
|
|
267
353
|
}
|
|
268
354
|
);
|
|
269
|
-
const
|
|
355
|
+
const he = F ?? (R ? R.message : null), ve = n && (e != null && e.isActive) && e.packageId ? {
|
|
270
356
|
isActive: !0,
|
|
271
357
|
activeContent: {
|
|
272
358
|
title: "Active Subscription",
|
|
@@ -286,55 +372,55 @@ function Ce({
|
|
|
286
372
|
] : []
|
|
287
373
|
]
|
|
288
374
|
}
|
|
289
|
-
} : void 0,
|
|
290
|
-
return /* @__PURE__ */
|
|
291
|
-
|
|
375
|
+
} : void 0, X = p === "free";
|
|
376
|
+
return /* @__PURE__ */ a(
|
|
377
|
+
P,
|
|
292
378
|
{
|
|
293
|
-
title:
|
|
294
|
-
className:
|
|
379
|
+
title: d,
|
|
380
|
+
className: v,
|
|
295
381
|
variant: "cta",
|
|
296
|
-
error:
|
|
297
|
-
currentStatus:
|
|
298
|
-
freeTileConfig:
|
|
299
|
-
aboveProducts:
|
|
300
|
-
|
|
382
|
+
error: he,
|
|
383
|
+
currentStatus: ve,
|
|
384
|
+
freeTileConfig: X ? g() : void 0,
|
|
385
|
+
aboveProducts: t.length > 1 ? /* @__PURE__ */ a("div", { className: "flex justify-center mb-6", children: /* @__PURE__ */ a(
|
|
386
|
+
fe,
|
|
301
387
|
{
|
|
302
|
-
options:
|
|
303
|
-
value:
|
|
304
|
-
onChange:
|
|
388
|
+
options: t,
|
|
389
|
+
value: p,
|
|
390
|
+
onChange: U
|
|
305
391
|
}
|
|
306
392
|
) }) : void 0,
|
|
307
|
-
children: !
|
|
308
|
-
|
|
309
|
-
/* @__PURE__ */
|
|
310
|
-
var
|
|
311
|
-
const
|
|
312
|
-
return /* @__PURE__ */
|
|
393
|
+
children: !X && /* @__PURE__ */ m("div", { className: "col-span-full space-y-6", children: [
|
|
394
|
+
S && /* @__PURE__ */ a("div", { className: "rounded-xl bg-gray-50 dark:bg-gray-800/50 border border-gray-200 dark:border-gray-700 p-5", children: S(p) }),
|
|
395
|
+
/* @__PURE__ */ a("div", { className: "space-y-3", children: T.map((o) => {
|
|
396
|
+
var ne, oe;
|
|
397
|
+
const s = (ne = o.product) == null ? void 0 : ne.period, y = s ? h(s, we[s] ?? ce(s)) : o.name, re = n && (e == null ? void 0 : e.isActive) && e.packageId === o.packageId, te = f && o.packageId !== f.packageId ? Ee(f, o) : null, Se = me(o), ae = be(o, p), ye = ((oe = o.product) == null ? void 0 : oe.priceString) ?? "$0";
|
|
398
|
+
return /* @__PURE__ */ m(
|
|
313
399
|
"div",
|
|
314
400
|
{
|
|
315
|
-
className: "flex items-center justify-between rounded-xl p-4 transition-all " + (
|
|
401
|
+
className: "flex items-center justify-between rounded-xl p-4 transition-all " + (re ? "bg-blue-50 dark:bg-blue-900/20 border-2 border-blue-500 dark:border-blue-400" : "bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700"),
|
|
316
402
|
children: [
|
|
317
|
-
/* @__PURE__ */
|
|
318
|
-
/* @__PURE__ */
|
|
319
|
-
/* @__PURE__ */
|
|
320
|
-
|
|
403
|
+
/* @__PURE__ */ m("div", { className: "min-w-0 flex-1", children: [
|
|
404
|
+
/* @__PURE__ */ a("p", { className: "text-base font-semibold text-gray-900 dark:text-gray-100", children: y }),
|
|
405
|
+
/* @__PURE__ */ a("p", { className: "text-xs text-gray-400 dark:text-gray-500", children: o.packageId }),
|
|
406
|
+
te !== null ? /* @__PURE__ */ m("p", { className: "text-sm font-medium text-green-600 dark:text-green-400", children: [
|
|
321
407
|
"Save ",
|
|
322
|
-
|
|
408
|
+
te,
|
|
323
409
|
"%"
|
|
324
|
-
] }) :
|
|
410
|
+
] }) : re ? /* @__PURE__ */ a("p", { className: "text-sm font-medium text-blue-600 dark:text-blue-400", children: "Current Plan" }) : null
|
|
325
411
|
] }),
|
|
326
|
-
|
|
412
|
+
/* @__PURE__ */ a(
|
|
327
413
|
"button",
|
|
328
414
|
{
|
|
329
|
-
onClick:
|
|
330
|
-
disabled:
|
|
415
|
+
onClick: ae,
|
|
416
|
+
disabled: z || !ae,
|
|
331
417
|
className: "ml-4 flex-shrink-0 rounded-lg px-4 py-2 text-sm font-semibold transition-colors bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",
|
|
332
|
-
children: `${
|
|
418
|
+
children: `${ye} · ${Se}`
|
|
333
419
|
}
|
|
334
420
|
)
|
|
335
421
|
]
|
|
336
422
|
},
|
|
337
|
-
|
|
423
|
+
o.packageId
|
|
338
424
|
);
|
|
339
425
|
}) })
|
|
340
426
|
] })
|
|
@@ -342,6 +428,6 @@ function Ce({
|
|
|
342
428
|
);
|
|
343
429
|
}
|
|
344
430
|
export {
|
|
345
|
-
|
|
346
|
-
|
|
431
|
+
$e as SubscriptionByDurationPage,
|
|
432
|
+
Ue as SubscriptionByOfferPage
|
|
347
433
|
};
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* SubscriptionByDurationPage
|
|
3
|
-
*
|
|
4
|
-
* Subscription page that groups packages by billing duration (monthly, yearly, etc.).
|
|
5
|
-
* Uses a SegmentedControl to switch between durations.
|
|
6
|
-
*/
|
|
1
|
+
import { SubscriptionPlatform, NetworkClient } from '@sudobility/types';
|
|
7
2
|
export interface SubscriptionByDurationPageProps {
|
|
8
3
|
/** Whether the user is logged in */
|
|
9
4
|
isLoggedIn: boolean;
|
|
@@ -21,5 +16,15 @@ export interface SubscriptionByDurationPageProps {
|
|
|
21
16
|
title?: string;
|
|
22
17
|
/** Additional CSS classes */
|
|
23
18
|
className?: string;
|
|
19
|
+
/** Current platform (defaults to Web) */
|
|
20
|
+
currentPlatform?: SubscriptionPlatform;
|
|
21
|
+
/** Network client for backend subscription fetch */
|
|
22
|
+
networkClient?: NetworkClient;
|
|
23
|
+
/** Backend API base URL */
|
|
24
|
+
baseUrl?: string;
|
|
25
|
+
/** Auth token for backend API */
|
|
26
|
+
token?: string;
|
|
27
|
+
/** Include sandbox purchases */
|
|
28
|
+
testMode?: boolean;
|
|
24
29
|
}
|
|
25
|
-
export declare function SubscriptionByDurationPage({ isLoggedIn, onNavigateToLogin, userId, userEmail, featuresByPackage, freeFeatures, title, className, }: SubscriptionByDurationPageProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export declare function SubscriptionByDurationPage({ isLoggedIn, onNavigateToLogin, userId, userEmail, featuresByPackage, freeFeatures, title, className, currentPlatform, networkClient, baseUrl, token, testMode, }: SubscriptionByDurationPageProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
import { SubscriptionPlatform, NetworkClient } from '@sudobility/types';
|
|
2
3
|
export interface SubscriptionByOfferPageProps {
|
|
3
4
|
/** Whether the user is logged in */
|
|
4
5
|
isLoggedIn: boolean;
|
|
@@ -16,6 +17,16 @@ export interface SubscriptionByOfferPageProps {
|
|
|
16
17
|
title?: string;
|
|
17
18
|
/** Additional CSS classes */
|
|
18
19
|
className?: string;
|
|
20
|
+
/** Current platform (defaults to Web) */
|
|
21
|
+
currentPlatform?: SubscriptionPlatform;
|
|
22
|
+
/** Network client for backend subscription fetch */
|
|
23
|
+
networkClient?: NetworkClient;
|
|
24
|
+
/** Backend API base URL */
|
|
25
|
+
baseUrl?: string;
|
|
26
|
+
/** Auth token for backend API */
|
|
27
|
+
token?: string;
|
|
28
|
+
/** Include sandbox purchases */
|
|
29
|
+
testMode?: boolean;
|
|
19
30
|
/**
|
|
20
31
|
* Translation function for localizing offer names, period labels, etc.
|
|
21
32
|
* Keys passed: offer identifiers (e.g. "basic", "premium"), "free",
|
|
@@ -35,4 +46,4 @@ export interface SubscriptionByOfferPageProps {
|
|
|
35
46
|
*/
|
|
36
47
|
initialOfferId?: string;
|
|
37
48
|
}
|
|
38
|
-
export declare function SubscriptionByOfferPage({ isLoggedIn, onNavigateToLogin, userId, userEmail, featuresByPackage: _featuresByPackage, freeFeatures, title, className, t: translate, renderOfferingContent, initialOfferId, }: SubscriptionByOfferPageProps): import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
export declare function SubscriptionByOfferPage({ isLoggedIn, onNavigateToLogin, userId, userEmail, featuresByPackage: _featuresByPackage, freeFeatures, title, className, currentPlatform, networkClient, baseUrl, token, testMode, t: translate, renderOfferingContent, initialOfferId, }: SubscriptionByOfferPageProps): import("react/jsx-runtime").JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sudobility/subscription_pages",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "Subscription page components for React web applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,14 +28,15 @@
|
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"react": "^18.0.0 || ^19.0.0",
|
|
30
30
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
31
|
-
"@sudobility/subscription_lib": "^0.0.
|
|
32
|
-
"@sudobility/subscription-components": "^1.0.
|
|
31
|
+
"@sudobility/subscription_lib": "^0.0.33",
|
|
32
|
+
"@sudobility/subscription-components": "^1.0.28",
|
|
33
33
|
"@sudobility/types": "^1.9.59"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@sudobility/subscription-components": "^1.0.
|
|
37
|
-
"@sudobility/subscription_lib": "^0.0.
|
|
36
|
+
"@sudobility/subscription-components": "^1.0.28",
|
|
37
|
+
"@sudobility/subscription_lib": "^0.0.33",
|
|
38
38
|
"@sudobility/types": "^1.9.59",
|
|
39
|
+
"@tanstack/react-query": "^5.91.2",
|
|
39
40
|
"@testing-library/jest-dom": "^6.0.0",
|
|
40
41
|
"@testing-library/react": "^16.0.0",
|
|
41
42
|
"@types/react": "^19.2.5",
|