@sudobility/subscription_pages 0.0.4 → 0.0.5

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.
Files changed (2) hide show
  1. package/dist/index.js +35 -34
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { jsx as i, jsxs as F } from "react/jsx-runtime";
1
+ import { jsx as i, jsxs as N } from "react/jsx-runtime";
2
2
  import { useState as C } from "react";
3
3
  import { usePackagesByDuration as ce, useUserSubscription as V, getSubscriptionInstance as X, refreshSubscription as Z, useAllOfferings as oe, useOfferingPackages as le, periodToMonths as J } from "@sudobility/subscription_lib";
4
- import { SubscriptionLayout as N, SubscriptionTile as se, SegmentedControl as ee } from "@sudobility/subscription-components";
4
+ import { SubscriptionLayout as F, SubscriptionTile as se, SegmentedControl as ee } from "@sudobility/subscription-components";
5
5
  function he({
6
6
  isLoggedIn: n,
7
7
  onNavigateToLogin: s,
@@ -10,20 +10,20 @@ function he({
10
10
  featuresByPackage: p,
11
11
  freeFeatures: u,
12
12
  title: f = "Choose Your Plan",
13
- className: S
13
+ className: k
14
14
  }) {
15
15
  const {
16
16
  packagesByDuration: I,
17
- availableDurations: v,
17
+ availableDurations: m,
18
18
  isLoading: g,
19
19
  error: P
20
20
  } = ce(), {
21
21
  subscription: r,
22
22
  isLoading: M,
23
23
  error: e
24
- } = V({ userId: d, userEmail: o }), [O, R] = C(null), [b, x] = C(null), [T, k] = C(!1), y = O ?? v[0] ?? null, w = g || M, A = P || e, E = async (t, h) => {
24
+ } = V({ userId: d, userEmail: o }), [O, R] = C(null), [b, x] = C(null), [T, S] = C(!1), y = O ?? m[0] ?? null, w = g || M, A = P || e, E = async (t, h) => {
25
25
  try {
26
- k(!0), x(null), await X().purchase({
26
+ S(!0), x(null), await X().purchase({
27
27
  packageId: t,
28
28
  offeringId: h,
29
29
  customerEmail: o
@@ -33,7 +33,7 @@ function he({
33
33
  l instanceof Error ? l.message : "Purchase failed"
34
34
  );
35
35
  } finally {
36
- k(!1);
36
+ S(!1);
37
37
  }
38
38
  }, L = () => n ? (r == null ? void 0 : r.isActive) && r.packageId ? {
39
39
  title: "Free",
@@ -79,10 +79,10 @@ function he({
79
79
  };
80
80
  if (w)
81
81
  return /* @__PURE__ */ i(
82
- N,
82
+ F,
83
83
  {
84
84
  title: f,
85
- className: S,
85
+ className: k,
86
86
  variant: "cta",
87
87
  children: /* @__PURE__ */ i("p", { children: "Loading subscription plans..." })
88
88
  }
@@ -109,22 +109,22 @@ function he({
109
109
  }
110
110
  } : void 0, D = y ? I[y] ?? [] : [];
111
111
  return /* @__PURE__ */ i(
112
- N,
112
+ F,
113
113
  {
114
114
  title: f,
115
- className: S,
115
+ className: k,
116
116
  variant: "cta",
117
117
  error: Y,
118
118
  currentStatus: j,
119
119
  freeTileConfig: L(),
120
- aboveProducts: v.length > 1 ? /* @__PURE__ */ i(
120
+ aboveProducts: m.length > 1 ? /* @__PURE__ */ i(
121
121
  ee,
122
122
  {
123
- options: v.map((t) => ({
123
+ options: m.map((t) => ({
124
124
  value: t,
125
125
  label: t.charAt(0).toUpperCase() + t.slice(1)
126
126
  })),
127
- value: y ?? v[0],
127
+ value: y ?? m[0],
128
128
  onChange: (t) => R(t)
129
129
  }
130
130
  ) : void 0,
@@ -173,7 +173,7 @@ function de(n, s) {
173
173
  );
174
174
  return f > 0 ? f : null;
175
175
  }
176
- function ve({
176
+ function me({
177
177
  isLoggedIn: n,
178
178
  onNavigateToLogin: s,
179
179
  userId: d,
@@ -181,9 +181,9 @@ function ve({
181
181
  featuresByPackage: p,
182
182
  freeFeatures: u,
183
183
  title: f = "Choose Your Plan",
184
- className: S,
184
+ className: k,
185
185
  t: I,
186
- renderOfferingContent: v
186
+ renderOfferingContent: m
187
187
  }) {
188
188
  var q;
189
189
  const g = (a, c) => I ? I(a, c) : c, {
@@ -194,20 +194,20 @@ function ve({
194
194
  subscription: e,
195
195
  isLoading: O,
196
196
  error: R
197
- } = V({ userId: d, userEmail: o }), [b, x] = C("free"), [T, k] = C(null), [y, w] = C(!1), A = ((q = P[0]) == null ? void 0 : q.offerId) ?? "", E = b !== "free" ? b : A, {
197
+ } = V({ userId: d, userEmail: o }), [b, x] = C("free"), [T, S] = C(null), [y, w] = C(!1), A = ((q = P[0]) == null ? void 0 : q.offerId) ?? "", E = b !== "free" ? b : A, {
198
198
  packages: L,
199
199
  isLoading: U,
200
200
  error: Y
201
201
  } = le(E), j = r || O || U, D = M || R || Y, t = async (a, c) => {
202
202
  try {
203
- w(!0), k(null), await X().purchase({
203
+ w(!0), S(null), await X().purchase({
204
204
  packageId: a,
205
205
  offeringId: c,
206
206
  customerEmail: o
207
207
  }), await Z();
208
- } catch (m) {
209
- k(
210
- m instanceof Error ? m.message : "Purchase failed"
208
+ } catch (v) {
209
+ S(
210
+ v instanceof Error ? v.message : "Purchase failed"
211
211
  );
212
212
  } finally {
213
213
  w(!1);
@@ -251,10 +251,10 @@ function ve({
251
251
  };
252
252
  if (j)
253
253
  return /* @__PURE__ */ i(
254
- N,
254
+ F,
255
255
  {
256
256
  title: f,
257
- className: S,
257
+ className: k,
258
258
  variant: "cta",
259
259
  children: /* @__PURE__ */ i("p", { children: "Loading subscription plans..." })
260
260
  }
@@ -281,10 +281,10 @@ function ve({
281
281
  }
282
282
  } : void 0, _ = b === "free";
283
283
  return /* @__PURE__ */ i(
284
- N,
284
+ F,
285
285
  {
286
286
  title: f,
287
- className: S,
287
+ className: k,
288
288
  variant: "cta",
289
289
  error: ae,
290
290
  currentStatus: ne,
@@ -297,19 +297,20 @@ function ve({
297
297
  onChange: x
298
298
  }
299
299
  ) }) : void 0,
300
- children: !_ && /* @__PURE__ */ F("div", { className: "col-span-full space-y-6", children: [
301
- v && /* @__PURE__ */ i("div", { className: "rounded-xl bg-gray-50 dark:bg-gray-800/50 border border-gray-200 dark:border-gray-700 p-5", children: v(b) }),
300
+ children: !_ && /* @__PURE__ */ N("div", { className: "col-span-full space-y-6", children: [
301
+ m && /* @__PURE__ */ i("div", { className: "rounded-xl bg-gray-50 dark:bg-gray-800/50 border border-gray-200 dark:border-gray-700 p-5", children: m(b) }),
302
302
  /* @__PURE__ */ i("div", { className: "space-y-3", children: L.map((a) => {
303
303
  var G, H;
304
- const c = (G = a.product) == null ? void 0 : G.period, m = c ? g(c, ue[c] ?? K(c)) : a.name, B = n && (e == null ? void 0 : e.isActive) && e.packageId === a.packageId, z = l && a.packageId !== l.packageId ? de(l, a) : null, Q = re(a), W = te(a, b), ie = ((H = a.product) == null ? void 0 : H.priceString) ?? "$0";
305
- return /* @__PURE__ */ F(
304
+ const c = (G = a.product) == null ? void 0 : G.period, v = c ? g(c, ue[c] ?? K(c)) : a.name, B = n && (e == null ? void 0 : e.isActive) && e.packageId === a.packageId, z = l && a.packageId !== l.packageId ? de(l, a) : null, Q = re(a), W = te(a, b), ie = ((H = a.product) == null ? void 0 : H.priceString) ?? "$0";
305
+ return /* @__PURE__ */ N(
306
306
  "div",
307
307
  {
308
308
  className: "flex items-center justify-between rounded-xl p-4 transition-all " + (B ? "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"),
309
309
  children: [
310
- /* @__PURE__ */ F("div", { className: "min-w-0 flex-1", children: [
311
- /* @__PURE__ */ i("p", { className: "text-base font-semibold text-gray-900 dark:text-gray-100", children: m }),
312
- z !== null ? /* @__PURE__ */ F("p", { className: "text-sm font-medium text-green-600 dark:text-green-400", children: [
310
+ /* @__PURE__ */ N("div", { className: "min-w-0 flex-1", children: [
311
+ /* @__PURE__ */ i("p", { className: "text-base font-semibold text-gray-900 dark:text-gray-100", children: v }),
312
+ /* @__PURE__ */ i("p", { className: "text-xs text-gray-400 dark:text-gray-500", children: a.packageId }),
313
+ z !== null ? /* @__PURE__ */ N("p", { className: "text-sm font-medium text-green-600 dark:text-green-400", children: [
313
314
  "Save ",
314
315
  z,
315
316
  "%"
@@ -335,5 +336,5 @@ function ve({
335
336
  }
336
337
  export {
337
338
  he as SubscriptionByDurationPage,
338
- ve as SubscriptionByOfferPage
339
+ me as SubscriptionByOfferPage
339
340
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sudobility/subscription_pages",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Subscription page components for React web applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -28,13 +28,13 @@
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.26",
31
+ "@sudobility/subscription_lib": "^0.0.27",
32
32
  "@sudobility/subscription-components": "^1.0.27",
33
33
  "@sudobility/types": "^1.9.58"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@sudobility/subscription-components": "^1.0.27",
37
- "@sudobility/subscription_lib": "^0.0.26",
37
+ "@sudobility/subscription_lib": "^0.0.27",
38
38
  "@sudobility/types": "^1.9.58",
39
39
  "@testing-library/jest-dom": "^6.0.0",
40
40
  "@testing-library/react": "^16.0.0",