@sudobility/subscription_pages 0.0.11 → 0.0.14

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 { jsx as c, jsxs as D } from "react/jsx-runtime";
2
- import { useState as y, useEffect as oe } from "react";
3
- import { usePackagesByDuration as le, useUserSubscription as V, getSubscriptionInstance as X, refreshSubscription as Z, useAllOfferings as se, useOfferingPackages as ue, periodToMonths as J } from "@sudobility/subscription_lib";
4
- import { SubscriptionLayout as $, SubscriptionTile as de, SegmentedControl as ee } from "@sudobility/subscription-components";
5
- function ve({
1
+ import { jsxs as m, jsx as a } from "react/jsx-runtime";
2
+ import { useState as C, useEffect as xe } from "react";
3
+ import { SubscriptionPlatform as le } from "@sudobility/types";
4
+ import { usePackagesByDuration as ke, useUserSubscription as se, useBackendSubscription as de, getSubscriptionInstance as ue, refreshSubscription as fe, useAllOfferings as Ce, useOfferingPackages as Ie, periodToMonths as ie } from "@sudobility/subscription_lib";
5
+ import { SubscriptionLayout as I, SubscriptionTile as Pe, SegmentedControl as pe } 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: l,
8
- userId: p,
9
- userEmail: o,
10
- featuresByPackage: f,
11
- freeFeatures: s,
12
- title: g = "Choose Your Plan",
13
- className: x
55
+ onNavigateToLogin: c,
56
+ userId: i,
57
+ userEmail: d,
58
+ featuresByPackage: b,
59
+ freeFeatures: f,
60
+ title: u = "Choose Your Plan",
61
+ className: v,
62
+ currentPlatform: P = le.Web,
63
+ networkClient: A,
64
+ baseUrl: w,
65
+ token: E,
66
+ testMode: _
14
67
  }) {
68
+ var O;
15
69
  const {
16
- packagesByDuration: I,
17
- availableDurations: h,
18
- isLoading: C,
19
- error: b
20
- } = le(), {
70
+ packagesByDuration: M,
71
+ availableDurations: S,
72
+ isLoading: x,
73
+ error: h
74
+ } = ke(), {
21
75
  subscription: r,
22
- isLoading: B,
23
- error: N
24
- } = V({ userId: p, userEmail: o }), [e, F] = y(null), [M, u] = y(null), [w, A] = y(!1), k = e ?? h[0] ?? null, R = C || B, P = b || N, E = async (t, m) => {
76
+ isLoading: j,
77
+ error: W
78
+ } = se({ userId: i, userEmail: d }), 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 === P, [N, $] = C(null), [q, s] = C(null), [U, F] = C(!1), k = N ?? S[0] ?? null, z = x || j, D = h || W, Q = async (t, p) => {
25
85
  try {
26
- A(!0), u(null), await X().purchase({
86
+ F(!0), s(null), await ue().purchase({
27
87
  packageId: t,
28
- offeringId: m,
29
- customerEmail: o
30
- }), await Z();
31
- } catch (d) {
32
- u(
33
- d instanceof Error ? d.message : "Purchase failed"
88
+ offeringId: p,
89
+ customerEmail: d
90
+ }), await fe();
91
+ } catch (g) {
92
+ s(
93
+ g instanceof Error ? g.message : "Purchase failed"
34
94
  );
35
95
  } finally {
36
- A(!1);
96
+ F(!1);
37
97
  }
38
- }, T = () => n ? (r == null ? void 0 : r.isActive) && r.packageId ? {
98
+ }, G = () => n ? (r == null ? void 0 : r.isActive) && r.packageId ? {
39
99
  title: "Free",
40
100
  price: "$0",
41
- features: s ?? [],
42
- ctaButton: {
43
- label: "Cancel Subscription",
44
- onClick: () => {
45
- r.managementUrl && window.open(r.managementUrl, "_blank");
46
- }
47
- }
101
+ features: f ?? []
48
102
  } : {
49
103
  title: "Free",
50
104
  price: "$0",
51
- features: s ?? [],
52
- ctaButton: {
53
- label: "Current Plan"
54
- },
55
- topBadge: { text: "Current Plan", color: "blue" }
105
+ features: f ?? [],
106
+ topBadge: { text: "Current", color: "blue" }
56
107
  } : {
57
108
  title: "Free",
58
109
  price: "$0",
59
- features: s ?? [],
110
+ features: f ?? [],
60
111
  ctaButton: {
61
112
  label: "Try it for Free",
62
- onClick: l
113
+ onClick: c
63
114
  }
64
- }, L = (t) => {
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: l
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 p = (r == null ? void 0 : r.isActive) && r.packageId, g = (r == null ? void 0 : r.packageId) === t.package.packageId && (r == null ? void 0 : r.offeringId) === t.offerId;
124
+ return p ? {
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 (R)
81
- return /* @__PURE__ */ c(
82
- $,
132
+ if (z)
133
+ return /* @__PURE__ */ a(
134
+ I,
135
+ {
136
+ title: u,
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
+ I,
83
145
  {
84
- title: g,
85
- className: x,
146
+ title: u,
147
+ className: v,
86
148
  variant: "cta",
87
- children: /* @__PURE__ */ c("p", { children: "Loading subscription plans..." })
149
+ children: /* @__PURE__ */ a(
150
+ ge,
151
+ {
152
+ backendSubscription: L.data,
153
+ managementUrl: r == null ? void 0 : r.managementUrl,
154
+ currentPlatform: P
155
+ }
156
+ )
88
157
  }
89
158
  );
90
- const U = M ?? (P ? P.message : null), Y = n && (r != null && r.isActive) && r.packageId ? {
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, j = k ? I[k] ?? [] : [];
111
- return /* @__PURE__ */ c(
112
- $,
179
+ } : void 0, R = k ? M[k] ?? [] : [];
180
+ return /* @__PURE__ */ a(
181
+ I,
113
182
  {
114
- title: g,
115
- className: x,
183
+ title: u,
184
+ className: v,
116
185
  variant: "cta",
117
- error: U,
118
- currentStatus: Y,
119
- freeTileConfig: T(),
120
- aboveProducts: h.length > 1 ? /* @__PURE__ */ c(
121
- ee,
186
+ error: J,
187
+ currentStatus: K,
188
+ freeTileConfig: G(),
189
+ aboveProducts: S.length > 1 ? /* @__PURE__ */ a(
190
+ pe,
122
191
  {
123
- options: h.map((t) => ({
192
+ options: S.map((t) => ({
124
193
  value: t,
125
194
  label: t.charAt(0).toUpperCase() + t.slice(1)
126
195
  })),
127
- value: k ?? h[0],
128
- onChange: (t) => F(t)
196
+ value: k ?? S[0],
197
+ onChange: (t) => $(t)
129
198
  }
130
199
  ) : void 0,
131
- children: j.map((t) => {
132
- var S;
133
- const m = n && (r == null ? void 0 : r.isActive) && r.packageId === t.package.packageId, d = L(t);
134
- return /* @__PURE__ */ c(
135
- de,
200
+ children: R.map((t) => {
201
+ var Y;
202
+ const p = n && (r == null ? void 0 : r.isActive) && r.packageId === t.package.packageId && r.offeringId === t.offerId, g = H(t);
203
+ return /* @__PURE__ */ a(
204
+ Pe,
136
205
  {
137
206
  id: t.package.packageId,
138
207
  title: t.package.name,
139
- price: ((S = t.package.product) == null ? void 0 : S.priceString) ?? "$0",
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: (f == null ? void 0 : f[t.package.packageId]) ?? [],
210
+ features: (b == null ? void 0 : b[t.package.packageId]) ?? [],
142
211
  isSelected: !1,
143
212
  onSelect: () => {
144
213
  },
145
- isCurrentPlan: m,
146
- ctaButton: d,
147
- disabled: w
214
+ isCurrentPlan: p,
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 K(n) {
224
+ function ce(n) {
156
225
  return n.charAt(0).toUpperCase() + n.slice(1);
157
226
  }
158
- const pe = {
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 fe(n, l) {
166
- if (!n.product || !l.product) return null;
167
- const p = J(n.product.period), o = J(l.product.period);
168
- if (p <= 0 || o <= 0 || p === 1 / 0 || o === 1 / 0 || p === o) return null;
169
- const f = n.product.price / p, s = l.product.price / o;
170
- if (f <= 0) return null;
171
- const g = Math.round(
172
- (f - s) / f * 100
234
+ function Ee(n, c) {
235
+ if (!n.product || !c.product) return null;
236
+ const i = ie(n.product.period), d = ie(c.product.period);
237
+ if (i <= 0 || d <= 0 || i === 1 / 0 || d === 1 / 0 || i === d) return null;
238
+ const b = n.product.price / i, f = c.product.price / d;
239
+ if (b <= 0) return null;
240
+ const u = Math.round(
241
+ (b - f) / b * 100
173
242
  );
174
- return g > 0 ? g : null;
243
+ return u > 0 ? u : null;
175
244
  }
176
- function Ce({
245
+ function Ue({
177
246
  isLoggedIn: n,
178
- onNavigateToLogin: l,
179
- userId: p,
180
- userEmail: o,
181
- featuresByPackage: f,
182
- freeFeatures: s,
183
- title: g = "Choose Your Plan",
184
- className: x,
185
- t: I,
186
- renderOfferingContent: h,
187
- initialOfferId: C
247
+ onNavigateToLogin: c,
248
+ userId: i,
249
+ userEmail: d,
250
+ featuresByPackage: b,
251
+ freeFeatures: f,
252
+ title: u = "Choose Your Plan",
253
+ className: v,
254
+ currentPlatform: P = le.Web,
255
+ networkClient: A,
256
+ baseUrl: w,
257
+ token: E,
258
+ testMode: _,
259
+ t: M,
260
+ renderOfferingContent: S,
261
+ initialOfferId: x
188
262
  }) {
189
- var q;
190
- const b = (a, i) => I ? I(a, i) : i, {
263
+ var Z, ee;
264
+ const h = (o, l) => M ? M(o, l) : l, {
191
265
  offerings: r,
192
- isLoading: B,
193
- error: N
194
- } = se(), {
266
+ isLoading: j,
267
+ error: W
268
+ } = Ce(), {
195
269
  subscription: e,
196
- isLoading: F,
197
- error: M
198
- } = V({ userId: p, userEmail: o }), [u, w] = y(
199
- C ?? "free"
270
+ isLoading: L,
271
+ error: B
272
+ } = se({ userId: i, userEmail: d }), 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 = !$ || $ === P, [s, U] = C(
279
+ x ?? "free"
200
280
  );
201
- oe(() => {
202
- C && w(C);
203
- }, [C]);
204
- const [A, k] = y(null), [R, P] = y(!1), E = ((q = r[0]) == null ? void 0 : q.offerId) ?? "", T = u !== "free" ? u : E, {
205
- packages: L,
206
- isLoading: U,
207
- error: Y
208
- } = ue(T), j = B || F || U, t = N || M || Y, m = async (a, i) => {
281
+ xe(() => {
282
+ x && U(x);
283
+ }, [x]);
284
+ const [F, k] = C(null), [z, D] = C(!1), Q = ((ee = r[0]) == null ? void 0 : ee.offerId) ?? "", G = s !== "free" ? s : Q, {
285
+ packages: T,
286
+ isLoading: H,
287
+ error: J
288
+ } = Ie(G), K = j || L || H, R = W || B || J, O = async (o, l) => {
209
289
  try {
210
- P(!0), k(null), await X().purchase({
211
- packageId: a,
212
- offeringId: i,
213
- customerEmail: o
214
- }), await Z();
215
- } catch (v) {
290
+ D(!0), k(null), await ue().purchase({
291
+ packageId: o,
292
+ offeringId: l,
293
+ customerEmail: d
294
+ }), await fe();
295
+ } catch (y) {
216
296
  k(
217
- v instanceof Error ? v.message : "Purchase failed"
297
+ y instanceof Error ? y.message : "Purchase failed"
218
298
  );
219
299
  } finally {
220
- P(!1);
300
+ D(!1);
221
301
  }
222
- }, d = [
223
- { value: "free", label: b("free", "Free") },
224
- ...r.map((a) => ({
225
- value: a.offerId,
226
- label: b(a.offerId, K(a.offerId))
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
- ], S = L[0] ?? null, re = () => n ? (e == null ? void 0 : e.isActive) && e.packageId ? {
229
- title: b("free", "Free"),
308
+ ], p = T[0] ?? null, g = () => n ? (e == null ? void 0 : e.isActive) && e.packageId ? {
309
+ title: h("free", "Free"),
230
310
  price: "$0",
231
- features: s ?? [],
232
- ctaButton: {
233
- label: "Cancel Subscription",
234
- onClick: () => {
235
- e.managementUrl && window.open(e.managementUrl, "_blank");
236
- }
237
- }
311
+ features: f ?? []
238
312
  } : {
239
- title: b("free", "Free"),
313
+ title: h("free", "Free"),
240
314
  price: "$0",
241
- features: s ?? [],
242
- ctaButton: {
243
- label: "Current Plan"
244
- },
245
- topBadge: { text: "Current Plan", color: "blue" }
315
+ features: f ?? [],
316
+ topBadge: { text: "Current", color: "blue" }
246
317
  } : {
247
- title: b("free", "Free"),
318
+ title: h("free", "Free"),
248
319
  price: "$0",
249
- features: s ?? [],
320
+ features: f ?? [],
250
321
  ctaButton: {
251
322
  label: "Try it for Free",
252
- onClick: l
323
+ onClick: c
253
324
  }
254
- }, te = (a) => n ? (e == null ? void 0 : e.packageId) === a.packageId ? "Current Plan" : (e == null ? void 0 : e.isActive) && e.packageId ? "Change Subscription" : "Subscribe" : "Log in to Continue", ae = (a, i) => {
255
- if (!n) return l;
256
- if ((e == null ? void 0 : e.packageId) !== a.packageId)
257
- return () => m(a.packageId, i);
258
- };
259
- if (j)
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 && (e == null ? void 0 : e.offeringId) === s ? "Manage Subscription" : "Change Subscription" : "Subscribe" : "Log in to Continue", be = (o, l) => n ? (e == null ? void 0 : e.isActive) && e.packageId ? Y : () => O(o.packageId, l) : c;
328
+ if (K)
329
+ return /* @__PURE__ */ a(
330
+ I,
262
331
  {
263
- title: g,
264
- className: x,
332
+ title: u,
333
+ className: v,
265
334
  variant: "cta",
266
- children: /* @__PURE__ */ c("p", { children: "Loading subscription plans..." })
335
+ children: /* @__PURE__ */ a("p", { children: "Loading subscription plans..." })
336
+ }
337
+ );
338
+ if (!q && N.data)
339
+ return /* @__PURE__ */ a(
340
+ I,
341
+ {
342
+ title: u,
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: P
351
+ }
352
+ )
267
353
  }
268
354
  );
269
- const ne = A ?? (t ? t.message : null), ce = n && (e != null && e.isActive) && e.packageId ? {
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, _ = u === "free";
290
- return /* @__PURE__ */ c(
291
- $,
375
+ } : void 0, X = s === "free";
376
+ return /* @__PURE__ */ a(
377
+ I,
292
378
  {
293
- title: g,
294
- className: x,
379
+ title: u,
380
+ className: v,
295
381
  variant: "cta",
296
- error: ne,
297
- currentStatus: ce,
298
- freeTileConfig: _ ? re() : void 0,
299
- aboveProducts: d.length > 1 ? /* @__PURE__ */ c("div", { className: "flex justify-center mb-6", children: /* @__PURE__ */ c(
300
- ee,
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
+ pe,
301
387
  {
302
- options: d,
303
- value: u,
304
- onChange: w
388
+ options: t,
389
+ value: s,
390
+ onChange: U
305
391
  }
306
392
  ) }) : void 0,
307
- children: !_ && /* @__PURE__ */ D("div", { className: "col-span-full space-y-6", children: [
308
- h && /* @__PURE__ */ c("div", { className: "rounded-xl bg-gray-50 dark:bg-gray-800/50 border border-gray-200 dark:border-gray-700 p-5", children: h(u) }),
309
- /* @__PURE__ */ c("div", { className: "space-y-3", children: L.map((a) => {
310
- var G, H;
311
- const i = (G = a.product) == null ? void 0 : G.period, v = i ? b(i, pe[i] ?? K(i)) : a.name, O = n && (e == null ? void 0 : e.isActive) && e.packageId === a.packageId, z = S && a.packageId !== S.packageId ? fe(S, a) : null, Q = te(a), W = ae(a, u), ie = ((H = a.product) == null ? void 0 : H.priceString) ?? "$0";
312
- return /* @__PURE__ */ D(
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(s) }),
395
+ /* @__PURE__ */ a("div", { className: "space-y-3", children: T.map((o) => {
396
+ var ne, oe;
397
+ const l = (ne = o.product) == null ? void 0 : ne.period, y = l ? h(l, we[l] ?? ce(l)) : o.name, re = n && (e == null ? void 0 : e.isActive) && e.packageId === o.packageId && e.offeringId === s, te = p && o.packageId !== p.packageId ? Ee(p, o) : null, Se = me(o), ae = be(o, s), 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 " + (O ? "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"),
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__ */ D("div", { className: "min-w-0 flex-1", children: [
318
- /* @__PURE__ */ c("p", { className: "text-base font-semibold text-gray-900 dark:text-gray-100", children: v }),
319
- /* @__PURE__ */ c("p", { className: "text-xs text-gray-400 dark:text-gray-500", children: a.packageId }),
320
- z !== null ? /* @__PURE__ */ D("p", { className: "text-sm font-medium text-green-600 dark:text-green-400", children: [
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
- z,
408
+ te,
323
409
  "%"
324
- ] }) : O ? /* @__PURE__ */ c("p", { className: "text-sm font-medium text-blue-600 dark:text-blue-400", children: "Current Plan" }) : null
410
+ ] }) : re ? /* @__PURE__ */ a("p", { className: "text-sm font-medium text-blue-600 dark:text-blue-400", children: "Current Plan" }) : null
325
411
  ] }),
326
- O ? /* @__PURE__ */ c("span", { className: "ml-4 flex-shrink-0 text-sm font-semibold text-blue-600 dark:text-blue-400", children: Q }) : /* @__PURE__ */ c(
412
+ /* @__PURE__ */ a(
327
413
  "button",
328
414
  {
329
- onClick: W,
330
- disabled: R || !W,
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: `${ie} · ${Q}`
418
+ children: `${ye} · ${Se}`
333
419
  }
334
420
  )
335
421
  ]
336
422
  },
337
- a.packageId
423
+ o.packageId
338
424
  );
339
425
  }) })
340
426
  ] })
@@ -342,6 +428,6 @@ function Ce({
342
428
  );
343
429
  }
344
430
  export {
345
- ve as SubscriptionByDurationPage,
346
- Ce as SubscriptionByOfferPage
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.11",
3
+ "version": "0.0.14",
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.31",
32
- "@sudobility/subscription-components": "^1.0.27",
31
+ "@sudobility/subscription_lib": "^0.0.34",
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.27",
37
- "@sudobility/subscription_lib": "^0.0.31",
36
+ "@sudobility/subscription-components": "^1.0.28",
37
+ "@sudobility/subscription_lib": "^0.0.34",
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",